๐Ÿ’ป Dev & CSC++ Programming

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 ํด๋ž˜์Šค๋ฅผ ์ž‘์„ฑํ•˜๋ผ. ...

March 9, 2020 ยท 3 min ยท Sobamemil