I was writing a brief program testing scope with a class and discovered a line that I do not understand. I fixed the problem but my question remains.
Here is my class.
Here is the fixed code. It ouputs "i'm alive" and "i'm dead" then finishes.Code:class aClass { public: aClass() { std::cout << "i'm alive\n"; } ~aClass() { std::cout << "i'm dead\n"; } };
Here is my questionable code.Code:int main(int argc, char * argv[]) { aClass A; }
I thought that by using A() I would be calling it's constructor. The code compiles but outputs nothing. I tried overloading the () operator, with a similar short message but nothing was outputted. What is the code aClass A() doing? Newbie question, thanks.Code:int main(int argc, char * argv[]) { aClass A(); }




Reply With Quote
