#include <iostream>
class Animal {
private:
int food;
int weight;
public:
void set_animal(int _food, int _weight) {
food = _food;
weight = _weight;
}
void increase_food(int inc) {
food += inc;
weight += (inc / 3);
}
void view_stat() {
std::cout << "이 동물의 food : " << food << std::endl;
std::cout << "이 동물의 weight : " << weight << std::endl;
}
}; // 세미콜론 잊지 말자!
int main() {
Animal animal;
animal.set_animal(100, 50);
animal.increase_food(30);
animal.view_stat();
return 0;
}
객체지향 프로그래밍 관련 내용 생략
클래스의 변수와 함수: 멤버 변수와 멤버 함수
인스턴스의 변수와 함수: 인스턴스 변수와 인스턴스 함수