What is the difference between Object b(); and Object b;?
To be more explicit, I get a compile time error when I try accessing an instance variable when I create an object using (), but when I don't, the code compiles and runs as expected. Also, this problem only applies to the default constructor. I would like to understand why. using namespace std; #include <iostream> class Student { public: int gpa; Student() { gpa = 4; } Student( int x ) { gpa = x; } }; int main() { Student zero; Student sally( 2 ); Student jack(); cout << zero.gpa << endl; //prints 4 cout << sally.gpa << endl; // prints 2 cout << jack.gpa << endl; //error: request for member