Programming/MFC
선언된 구조체 또는 변수들의 초기화
쾌변용자
2010. 11. 8. 18:02
선언된 구조체 또는 변수를 초기화 하고 싶은 경우
해당 다이얼로그(클래스) 생성자에서 초기화를 수행하면 된다
Document.h 에서 선언된 구조체를 Document.cpp에서 초기화 하는 예제
CIvyClubDoc::CIvyClubDoc()
{
// TODO: add one-time construction code here
Counter = 0;
//----ITEM 구조체 초기화
memset(strITEM, 0, sizeof(strITEM));
HeadCounter = 0;
}
위의 방식으로 초기화시 구조체에 CString이 있으면 에러가 발생함
common.h
typedef struct tagITEM
{
int index;
int s85[A_KIND];
int s90[A_KIND];
int s95[A_KIND];
int s100[A_KIND];
}ITEM;