include
using namespace std;
class A{
public:
void func()
{
cout << "hahaha" << endl;
}
int m_num = 1;
};
int main()
{
A* ptr = NULL;
A obj;
obj.func();
cout<<obj.m_num<<endl;
ptr->func();
cout<m_num;
return 0;
}输出结果
cpp
hahaha
1
hahaha
```
不能调用类成员变量