목록C++ (45)
printf("ho_tari\n");
#include #include "shape.h" #include "rectangle.h" #include "circle.h" void printArea(const Shape *ps) { std::cout
#include #include "safeArray.h" #include "array.h" int main() { int nums[] = {1, 2, 3, 4, 5}; //Array arr(nums, 5); SafeArray arr(nums, 5); //arr[5] = 6; // polymorphism Array *pArr = new SafeArray(nums, 5); (*pArr)[5] = 6; // pArr->operator[](5) delete pArr; Array &rArr = arr; return 0; } #ifndef SAFEARRAY_H #define SAFEARRAY_H #include "array.h" class SafeArray : public Array { private: public..
#include #include "safeArray.h" #include "array.h" int main() { SafeArray arr1; SafeArray arr2(100); int nums[] = {1,2,3,4,5}; SafeArray arr3(nums,5); const SafeArray arr4 = arr3; arr1 = arr4; if (arr1 == arr4) { std::cout Array::operator[](index); }
#include #include "queue.h" int main() { //Queue q1; // Queue q1(100); //Queue q2(10); // Queue q2 = 10; //Queue q3 = q2; //q1 = q2; Queue s1(10), s2(100); s1.push(100); s1.push(200); std::cout
#include #include "queue.h" int main() { //Queue q1; // Queue q1(100); //Queue q2(10); // Queue q2 = 10; //Queue q3 = q2; //q1 = q2; Queue s1(10), s2(100); s1.push(100); s1.push(200); std::cout
#include #include "stack.h" int main() { Stack s1(10); Stack s2(100); s1.push(100); //구조체 자료는 인자를 전달할 때 오버헤드를 줄이기 위해 포인터를 쓴다. s1.push(200); s1.push(300); std::cout
#include "list.h" #include #include int main(void) { List list; //insertFirstNode(&list, 4); // [4] list.insertFirstNode(4); list.printList(); //insertFirstNode(&list, 3); // [3, 4] list.insertFirstNode(3); list.printList(); //insertFirstNode(&list, 1); // [1, 3, 4] list.insertFirstNode(1); list.printList(); //insertNode(&list, 1, 2); // [1, 2, 3, 4] list.insertNode(1, 2); list.printList(); //de..