这个对象声明有什么问题?

时间:2018-12-01 13:46:50

标签: c++ class object

#include <iostream>
using namespace std;

class A {
    public:
        int x;
    A() {
        x=1;
        cout << x <<endl;
    }
};

int main()
{
    A b();
    cout << b.x << endl;
    return 0;
}

运行此命令会导致编译错误:错误:请求'b'中的成员'x',该成员属于非类类型'A()'“ cout << b.x <

0 个答案:

没有答案
相关问题