Originally Posted by gregorian
Ok, I included cla.class1(); in the main() function.
What does that mean?
You are using illegal syntax in your class--it's as simple as that. In a class you can have things like declarations of variables, e.g.:
declarations of functions, e.g.:
and blocks of code. One example of a legal block of code is a group of statements that is surrounded by braces and serves as a function definition and is immediately preceded by the function header(return type, function name, parameters), e.g.:
int myFunc(int n)
violates about every syntax rule in C++. The line:
int i = 0;
looks like a declaration of a member variable, but it is an illegal statement; you can't assign a value to a member variable in a class definition(one exception). This line:
is strictly illegal in a class definition; it's not a declaration of a member variable; it's not a function declaration; and it's not inside a block of code that is part of a function definition.
Why isn't it invoking the default constructor?
Your code doesn't compile, so the code cannot execute, and therefore no default constructor is called.