c(3)
-
[C++] 멤버함수응용 : monster 사냥
1. #include #include using namespace std; // Monster의 구조체 // 모든 몬스터의 정보를 출력하는것은 적합하지 않다 // why? 멤버함수이기 때문이다. struct Monster { // Monster의 속성 string name; string dropItem; int hp; int atk; int level; void PrintInfo() { cout
2022.06.02 -
[C++] 외부함수들을 멤버함수로 변환하고 비교해보기(구조체)
* 멤버함수가 무엇인지, 외부함수는 무엇인지 서로 비교하고 어떤 상황에서 유리한지 생각해보자. * 코딩의 전체적인 구조나 흐름은 멤버함수를 짤때 더 효율적이고 가속성이 좋은 것 같다. // 실습_구조체변수를 멤버변수로 썼던 외부함수들을 멤버함수로 변환시켜보자 #include #include using namespace std; struct Monster { string name; int lv; int hp; int damage; // 멤버함수 void PrintInfo() { cout
2022.06.02 -
[C++] 특정한 값을 출력하는 구조체를 만들어보자
1. #include #include using namespace std; // 구조체 변수 선언 struct Monster { string name; int lv; int hp; int damage; }; struct Computer { string name; int price; }; // 구조체의 멤버변수들을 출력하는 함수 void PrintInfo(Monster target) { cout
2022.06.02