#include <stdio.h>
struct st {
int no;
char ch;
void InitData(void);
void OutputData(void) const;
};
void main()
{
struct st aa;
aa.InitData();
aa.OutputData();
}
void st::InitData(void)
{
no=5;
ch='A';
}
void st::OutputData(void) const
{
printf("%d\t%c\n", no, ch);
}
구조체 안에 함수가 들어 갈 수 있다.
st:: 의 사용법도.
함수의 정의 자체가 구조체안에 들어 갈수도 있다.
#include <stdio.h>
struct st {
int no;
char ch;
void InitData(void)
{
no=5;
ch='A';
}
void OutputData(void) const
{
printf("%d\t%c\n", no, ch);
}
};
void main()
{
struct st aa;
aa.InitData();
aa.OutputData();
}
이렇게
댓글 없음:
댓글 쓰기
국정원의 댓글 공작을 지탄합니다.