I have the following class:
class aClass {
public:
aClass():a(0){}
void print(){cout<<a<<endl;}
private:
int a;
};
In main() function I accidentally create an object like this:
aClass obj();
I thought the compiler will throw an error as it is expected to call the default copy constructor, but there is no argument inside the bracket (). Interestingly, there is no error at all. So I try to access a member function by calling:
obj.print();
Now it throws this error:
request for member 'print' in 'obj', which is of non-class type 'aClass()'
Can somebody explain it to me? What is obj() that has been created?