c语言里声明了结构体后,在定义结构体变量时,要如下形式:
struct A { // 声明结构体A
int a;
};
struct A a_st; // 定义结构体
struct A *a_p; // 定义结构体指针
为了方便使用,c里面通常用typedef来声明结构体:
typedef struct _A{ // 用typedef声明结构体
int a;
} A, *PA;
A a_st; //定义结构体
PA a_p; //定义结构体指针
但是在c++中,结构体的在定义的时候,struct关键字是不必要的
struct A { // 声明结构体
int a;
};
A a_st; //定义结构体
A* a_p; // 定义结构体指针
我的问题是,在c++中,还有必要使用typedef的方式来声明结构体吗?