클래스에 멤버변수를 선언하고 객체에서 사용했다. 좀 더 완성된 형태의 클래스
--------
class CS{
public:
int a, b;
void swap()
{
int temp;
temp = a;
a=b;
b =temp;
}
};
--------
#include <stdio.h>
#include "CS3.h"
int main()
{
CS cs1;
cs1.a = 3;
cs1.b = 5;
cs1.swap();
printf("a=%d, b=%d\n", cs1.a, cs1.b);
return 0;
}
댓글 없음:
댓글 쓰기