using namespace std;
class A{
public:
A(){};
~A(){}
void Print(){
cout<<"A"<<endl;
}
virtual void Print2(){
cout<<"A2"<<endl;
}
void display(){
cout<<a<<endl;
}
private:
int a=2;
};
int main()
{
A* a;
a->Print();
a->Print2();
a->display();
}
为什么a->Print();能调用成功而后面两行调用都会出现段错误呢
全部评论
(4) 回帖