c++结构体的构造函数和初始化

#include 

struct test1{
    int a;
    int b;
    int *p;
};
using namespace std;
int main()
{
    test1 t1 = { 1, 2, NULL };
    int *ptr = new int();
    test1 t2 = { 1, 2, ptr };
    cout << t1.a << " " << t1.b << " " << t1.p << endl;
    cout << t2.a << " " << t2.b << " " << t2.p << endl;
    system("pause");
    return 0;
}
1 2 00000000
1 2 010BA380
请按任意键继续. . .

你可能感兴趣的:(c++结构体的构造函数和初始化)