A Foo () // why it is not giving compilation error since return type is A and I'm not mention return
{
}
int main ()
{
A a(); // why constructor or destructor is not geting called??
cout<<"End of main "<<endl;
}
A Foo () // why it is not giving compilation error since return type is A and I'm not mention return
{
}
int main ()
{
// A a(); // why constructor or destructor is not geting called??
Foo ();
cout<<"End of main "<<endl;
return 0;
}
Behavior seems to be very much compiler specific.
When I tried on VC++ 6 compiler, i got below error
"E:\CPP\test4\test4.cpp(16) : error C4716: 'Foo' : must return a value"
When i tried with Sun CC compiler, i got below error
""test.cpp", line 12: Error: "Foo()" is expected to return a value."
When i tried with Sun g++ compiler, it compiled fine. At runtime, It is printing only below message "End of main " only.