#include <iostream> using namespace std; class A{ public: int num; //A():num(100) { cout << "无参构造函数" << endl; } }; int main() { A a; cout << ( a.num==0 ) << endl; cout << ( A().num==0 ) << endl; //无名对象, 类名后带括号 A *p1 = new A; cout << ( p1->num==0 ) << endl; A *p2 = new A(); //动态创建对象, 类名后带括号 cout << ( p2->num==0 ) << endl; return 0; }