Nov 5, 2015 at 11:53pm UTC
It declares a function named a1 that returns a value of type A; this is known as "the most vexing parse" if you are interested in Googling it.
Nov 5, 2015 at 11:53pm UTC
A a1();
is the declaration of a function named a1 that takes no arguments and returns an object of type A .
Nov 6, 2015 at 12:00am UTC
Thanks. so if a1() is a function and I add something like
void a1(){
cout << "HEY";
}
in the class why doesn't print HEY?!
Last edited on Nov 6, 2015 at 12:28am UTC
Nov 6, 2015 at 12:02am UTC
All that line does is declare a function. It does not actually call anything. If you want to call a1(), you will need to do that explicitly.
Nov 6, 2015 at 12:02am UTC
Presumably you meant a1 and not z1 . As I said, it's a function declaration. It is not calling a function. If it were calling a function and the function didn't exist, you would encounter a linking error.