69,371
社区成员
发帖
与我相关
我的任务
分享
struct point
{
struct point1
{
int x;
int y;
} p1; //加入struct point的 域名 (c++叫成員變量名)
struct point2
{
int x;
int y;
} p2;
};
int main()
{
//struct point point1 pt1; //這個是錯的
struct point2 pt2; // gcc 可以
//這樣寫可以
struct point pt;
return 0;
}
struct point
{
struct point1
{
int x;
int y;
};
struct point2
{
int x;
int y;
};
point1 a;
point2 b;
};
int main()
{
struct point p;
p.a.x=1;
p.b.y=2;
//struct point rect
system("pause");
return 0;
}
#include <stdio.h>
typedef struct point1
{
int x;
int y;
}point1;
typedef struct point
{
point1 p1;
point1 p2;
}point;
int main()
{
point pt;
point1 pt1;
//struct point rect
}
刚刚copy错了,参考这个#include <stdio.h>
struct point
{
struct point1
{
int x;
int y;
};
struct point2
{
int x;
int y;
};
};
int main()
{
struct point point1 pt1;
//struct point rect
}
参考这个代码用吧