캡슐화 (1) 썸네일형 리스트형 [C++] 구조체를 확장하면? 클래스! # C의 구조체는 서로 다른 타입의 집합입니다. #include #include struct Student{// 구조체 int age; char name[25]; }; void printStudent(Student s){ printf("나는 %d살, %s입니다.\n", s.age, s.name); } int main() { Student s; s.age = 20; strcpy(s.name, "홍길동"); printStudent(s); return 0; } 출력 결과: 나는 20살, 홍길동입니다. # 여기에서 구조체 Student와 함수 printStudent 는 서로 상호의존적입니다. Student는 printStudent가 없으면 화면에 출력할 수가 없고, printStudent도 Student가 없으.. 이전 1 다음