C语言结构体可以包含另一个结构体;
下面通过一个例子看一下;
struct Date {
int day;
int month;
int year;
};
struct Person {
char *name;
struct Date birthday;
};
......
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString str1;
struct Person p1;
p1.name = "John.Chen";
p1.birthday.day = 23;
p1.birthday.month = 7;
p1.birthday.year = 1987;
str1.Format("%s, %d, %d, %d", p1.name, p1.birthday.year, p1.birthday.month, p1.birthday.day);
pDC->TextOut(50, 50, str1);
}