Develop/C++

Develop/C++

클래스의 활용

1학년 때 시험대비할 겸 정리했던 글 *객체들의 배열 #include #include using namespace std; class Car { int speed; int gear; string color; public: Car(int s = 0, int g = 1, string c = "white") :speed(s), gear(g), color(c) { } void print() { cout

Develop/C++

클래스와 객체 ~ 생성자 정리

1학년 때 시험 대비 할겸 정리해놨던 글 *절차지향 프로그래밍 : 데이터와 함수가 묶여있지 않다. 객체지향 프로그래밍 : 데이터와 함수가 묶여있다. ​ *객체는 상태와 동작을 가진다 객체의 상태 : 객체의 속성 객체의 동작 : 객체가 취할 수 있는 동작 ​ *접근지정자 private 멤버는 클래스 안에서만 접근될 수 있다. protected 멤버는 클래스안 & 상속된 클래스에서 접근가능 public 멤버는 어디서나 접근 가능 ​ *객체의 멤버 접근 obj라는 객체의 radius 멤버 변수에 접근하려면 obj.radius = 3; 처럼 . 연산자를 사용 #include using namespace std; class Circle { public: int radius; string color; double ..

dawonny
'Develop/C++' 카테고리의 글 목록