c++ - 这个对象声明有什么问题?
问题描述
#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<< bx <
解决方案
推荐阅读
- css - 下拉菜单隐藏在父元素后面
- javascript - 在移动设备上缩放 ThreeJS 视图
- windows-10 - 在 Windows 10 上将 Perl 6 安装到 MSYS2
- angular - Angular如何在调用Web服务时禁用屏幕
- java - 如何在使用 selenium 通过 chrome 下载时更改文件名
- javascript - 图像被多次下载
- swt - ChartComposite 变成一个滚动的Composite
- android - 在 Android 应用程序的 ViewGroup 的“onInterceptTouchEvent”方法中,ACTION_MOVE 事件能否在 ACTION_DOWN 事件之前到达?
- c++ - 在 C++ 中使用 while 循环查找一组数字中的最小值的程序
- html - 视频 I 帧在移动浏览器上无法正常工作