What is the difference between Object b(); and Object b;?

后端 未结 5 1902
执念已碎
执念已碎 2021-01-23 07:49

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 expe

5条回答
  •  日久生厌
    2021-01-23 08:33

      Student jack();
    

    declares a function that returns student and takes no arguments. Not an object!

    See more in this gotw

提交回复
热议问题