C++ Programming Ch.8 Exercise 5 Solution
Problem: ๋ฌธ์ 5~6์ ์ ์ฉ๋๋ BaseArray ํด๋์ค๋ ๋ค์๊ณผ ๊ฐ๋ค. 1 2 3 4 5 6 7 8 9 10 11 12 class BaseArray { int capacity; // ๋ฐฐ์ด์ ํฌ๊ธฐ int *mem; // ์ ์ ๋ฐฐ์ด์ ๋ง๋ค๊ธฐ ์ํ ๋ฉ๋ชจ๋ฆฌ์ ํฌ์ธํฐ protected: // ์์ฑ์๊ฐ protected BaseArray(int capacity=100){ this->capacity = capacity; mem = new int [capacity]; } ~BaseArray() { delete [] mem; } void put(int index, int val) { mem[index] = val; } int get(int index) { return mem[index]; } int getCapacity() { return capacity; } }; BaseArray๋ฅผ ์์๋ฐ์ ํ์ฒ๋ผ ์๋ํ๋ MyQueue ํด๋์ค๋ฅผ ์์ฑํ๋ผ. ...