Possible Duplicate:
constructor invocation mechanism
It took me long to figure this problem. So I was curious to know the difference between them. Below is the code snippet:
struct Test
{
Test () { cout<<" Test()\n"; }
~Test () { cout<<"~Test()\n"; }
};
int main()
{
Test obj(); // Remove braces of 'obj' & constructor/destructor are printed
}
Wanted to know that, why such behavior ? Is there any fundamental difference between declaring an object with/without empty braces (here we talk only about the cases of default constructor). Code is compiled one of the latest versions of Ubuntu/g++. Sorry if, it's a repeat question.