Possible Duplicate:
Why is it an error to use an empty set of brackets to call a constructor with no arguments?
I bumped into the following problem. I created 2 instances of foo.
Then I realized, that foo f();
didn't execute the contructor of a class. Why is that?
class foo{
public:
foo() {cout <<"executed contructor...";}
};
int main() {
foo f(); // doesn't run the ctor???? why?
foo f2; // this one does execute the ctor
system("pause");
return 0;
}