+ 4
Why there is no output?
class A{ public: A (){ cout <<"hi";} A (int a=0){ cout <<"hello";} }; int main() { A a(); } And if write like this A a; then there is an error....
2 Answers
+ 2
I think there is no output because the compiler doesnt know which constructor he is supposed to call, since you specified a default value for the variable.
It works if you remove the default value and either call the constructor without parentheses (first one) or with a value (second one).
+ 1
int main()
{
A a();
}
you declare a function "a" with return type "A" here
e.g. check it out...
int main()
{
A a();
a();
}
A a(){
std::cout << " i am a function " << std::endl;
}