// 方法1: C 和 C++ 都可以用
// =====================
typedef struct Student
{
int id;
char* name;
}Student;
Student student = {1, "Sean"};
{
int id;
char* name;
}Student;
Student student = {1, "Sean"};
// =====================
// 方法2: C 和 C++ 都可以用
// =====================
// ==============================
struct Student
{
int id;
char* name;
};
typedef struct Student student;
Strudent student = {1, "Sean"};
// ==============================
// 方法3: 不需 typedef 只有 C++ 可以用
// ==============================
// ==============================
struct Student
{
int id;
char* name;
};
Strudent student = {1, "Sean"};
沒有留言:
張貼留言