1.C 中 struct 的常见使用方法
struct Mystruct{
int x;
int y;
}ms1;
struct Mystruct ms2;
ms1.x = 1;
ms1.y = 2;
ms2.x = 3;
ms2.y = 4;
typedef struct Mystruct{
int x;
int y;
}Mystruct2 ,*PMystruct;
struct Mystruct ms1;
Mystruct2 ms2;
PMystruct pms = &ms2;
ms1.x = 1;
ms1.y = 2;
ms2.x = 3;
ms2.y = 4;
2.C++ 中 struct 的使用方法
struct Mystruct{
int x;
int y;
}ms1;
Mystruct ms2;
ms1.x = 1;
ms1.y = 2;
ms2.x = 3;
ms2.y = 4;
struct Mystruct{
int x;
int y;
void setz(int x);
int getz(void);
private:
int z;
};
Mystruct ms;
ms.x = 1;
ms.y = 2;
ms.setz(3);
int z = ms.getz();
struct 的其他使用方法
struct {
int x;
int y;
}ms1;
ms1.x = 1;
ms1.y = 2;
typedef struct{
int x;
int y;
}Mystruct;
Mystruct ms1;