如何使c++结构体包含其他结构体作为成员变量
How to make a C++ structure contain other structure as member variable
我想知道如何在来自另一个结构的结构中定义变量。例如:
struct Date
{
int month;
int day;
int year;
};
struct Profile
{
START DATE
END DATE
int hours_worked
etc...
};
struct Profile {
Date start;
Date end;
// etc...
};
这就是你想要的吗?如果是这样的话,我强烈建议你手头有一本教科书,而不是把它作为你解决c++问题的首选,直到你更熟练为止。如果没有,请更新您的问题
相关文章:
- C++ - 如何在结构向量中找到结构体一个成员的最大值?
- 在C++中使用链表的堆栈实现中,访问结构体headNode成员count和top会导致运行时错误
- 如何获取结构体成员的地址
- 访问不同类的私有结构体成员
- C++ 使用成员函数返回结构体指针属性的值
- 通过函数参数确定结构体成员
- 如何使用其他函数返回的值为结构体成员赋值
- 当我想为结构体声明新成员时,有些麻烦我不明白
- CUDA:结构体的共享数据成员和对该结构体的引用成员具有不同的地址和值
- 按结构体的特定成员对结构体数组进行排序
- 如何在编译时输出结构体中成员的偏移量(C/ c++)
- Vector::erase()也擦除结构体的成员向量
- 模板结构体的静态const成员的不同值
- 比较值与结构体成员的问题
- 从二进制文件中提取结构体成员
- 为什么我的结构体成员没有使用"{}"正确初始化?
- 函数参数 -> 结构体成员的 void* 和常量 void* 的解决方案
- 动态结构体成员在使用 CUDA/NVCC 传递到函数时损坏
- 将相同的变量赋给具有不同值的多个结构体成员
- 为什么编译器不能像变量声明那样在结构体成员中设置 char[] = { .. } 的大小?