What will be printed out as a result of the following program execution?
#include <iostream>

using namespace std;

class Clazz {
    int a;
    const int b;
    int c;

public:
    Clazz(int a, int b):a(a - 1),b(b),c(a - 2) {}
    void print() {
        cout << a << b << c << endl;
    }
};

int main() {
    Clazz x(5, 10);
    x.print();
    return 0;
}
Explanation
Any text outside the parentheses represents the class fields since it's an initialization list. Text inside the parentheses represents constructor arguments as they overlay class fields because of the coincidence of names.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback