코딩 1막 <C++개념편>/코딩 1막 <C++응용편>(34)
-
[C++] 절대 변하지 않을 변수를 상수화를 시켜보자
#define PI 3.1415f #define COL 100 #define ROW 64.9f const float pi = 3.1415f; void Func(const int& inputA, const int& inputB)// 참조자 & : 별명이라고 생각하셈. 참조자는 공간을 쓰지 않는다. { cout
2022.06.27 -
[C++] 큐와 스택 만들기(자료구조 헬 입성)
*head-tail / front-rear / start-end 방법1. 단방향 큐/스택 만들기 1.1 단방향 큐 #include #include #include using namespace std; class Node { public: int value; Node* next = nullptr; }; // 큐 만들기 class Queue { private: Node* head = nullptr; Node* tail = nullptr; int size = 0; public: void Enqueue(int value);// 넣는거 int Dequeue();// 빼는거 int GetSize();// size게터 bool IsEmpty();// 비어있는지 확인 void Show();// 전체 출력 }; void..
2022.06.23 -
[C++] 플레이어 클래스를 만들고, 게터와 세터 생성하기
#include #include using namespace std; class Player { private: string name; int hp = 2 * (atk + def) ; int halfHp = hp / 2; int atk; int def = atk / 2; string job; bool isBerserk = false; bool die = false; public: int GetHp() { return hp; } int GetAtk() { return atk; } int GetDef() { return def; } void SetHp(int value) { hp = value; if (hp
2022.06.22 -
[C++] 클래스와 구조체의 비교
1. #include #include using namespace std; struct TravelToWorld { string name; int time; int money; TravelToWorld() { cout
2022.06.22 -
[C++] 추리게임 오프닝 만들기
#include #include #include using namespace std; void SetColor(int colorNumber) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorNumber); } struct Detective { string name; int inspriation; int healthGage; int maxHealthGage; void SetProfile() { system("cls"); cout
2022.06.16 -
[C++] 게임 오프닝 만들기
#include #include using namespace std; // 구조체 선언부 struct Player; struct Warrior; struct Wizard; void Opening(); void Start(); // 구조체 정의부 struct Player { string name; int hp; int atk; string job; }; struct Warrior : Player { Warrior(); Warrior(string _name, int _hp, int _atk, string _job); void ShowInfo(); }; struct Wizard : Player { Wizard(); Wizard(string _name, int _hp, int _atk, string _job);..
2022.06.16