C++结构体用法
struct为结构体关键字,tag为结构体标签,member_list即为所需要的成员的类型以及名称,variable_list即为结构体变量名
struct tag
{
member_list;
}variable_list;
示例
struct node
{
int age;
string name;
} student1, student2;
*********************
struct node
{
int age;
string name;
};
node student1, student2;
**********************
struct
{
int age;
string name;
}s1;
另外,值得注意的一点是C++中的结构体内是可以有函数的(C语言中则没有),而结构体与类的区别则为class中成员变量访问权限与继承默认为private,而结构体中则为public。