C++ #명품C++ #C언어 프로그래밍 #명품C++프로그래밍 실습문제 #실습문제 47

[C++] 명품 C++ 프로그래밍 실습문제 6장 8번

[C++]명품 C++ 프로그래밍 실습문제 6장 8번 [C++]명품 C++ programming 실습문제 6장 8번 #include #include using namespace std; void f(); class Trace{ static string *s1;//tag 정보 저장 //static 선언하면 전역공간에서 구현을 간략히 해줘야 풀수가 있음 static string *s2;//내용 정보 저장 static int num; public: static void put(string tag, string imformation){ s1[num] = tag; s2[num] = imformation; num++; } static void print(string tag){ if( tag == "f()" ){ cout

C++ 2023.01.10

명품 C++ 실습문제 5장 12,12-1번

12-1번 #include #include using namespace std; class Dept { int size; int* scores; public: Dept(int size) { this->size = size; scores = new int[size]; } //생성자 /*Dept(const Dept& dept) { this->size = dept.size; this -> scores = new int[size]; for (int i = 0; i < size; i++) { scores[i] = dept.scores[i]; } }*///복사생성자 //~Dept() { delete[] scores; }//소멸자 소멸자를 적지 않는다면 힙메모리를 터트릴게 없어서 상관이 없어진다 int getSize..

C++ 2023.01.05

명품 C++ 실습문제 5장 8번

#include using namespace std; class MyIntStack{ int *p; int size; int tos; public: MyIntStack(int size){//매개생성자 인라인함수로 넣기 this->p = new int[size]; this->size = size; this->tos = -1;}//인덱스 리턴//매개생성자 MyIntStack(const MyIntStack &s){//복사 생성자 int len = s.size; this->p = new int[len]; this->size = len; this->tos = s.tos; for (int i = 0; i p[i] = s.p[i]; }//복사 생성자 ~MyIntStack(){delete [] p;} bool push..

C++ 2023.01.05