typedef struct {
int data;
int text;
} S1;
//这种方法可以在c或者c++中使用
struct S2
{
int data;
int text;
};
//C++中上面的代码类似于类,可以用 S2 s再定义一个变量;C语言定义变量需要用sruct S2 s。
struct {
int data;
int text;
} S3;
//这种方法并没有定义一个结构,而是定义了一个S3的结构变量。
struct S4 {
S4* ptr;
};
// 这种写法只能在C++中使用,S4类似一个类
typedef struct tagS5{
struct tagS5 * ptr;
} S5;
//如果在C中,可以这样使用
typedef struct {
S6* ptr;
} S6;
// 这是一种在C和C++中都是错误的定义
typedef struct Student
{
int a;
}Stu;
typedef struct
{
int a;
}Stu;
struct Stu
{
int a;
};
//三种C++里都可以使用St