목록2021-2학기/C++ (15)
Jam's story
1 T big 이부분 main 안에서 배열을 다 int로 선언했던 실수 #include #include #include #include using namespace std; template T biggest(T a[], int size) { T big = a[0]; for (int i = 1; i big) big = a[i]; } return big; } int main() { int x[] = { 1,2,3,4,5 }; cout
#include using namespace std; class Converter { protected: double ratio; virtual double convert(double src) = 0; virtual string getSourceString() = 0; virtual string getDestString() = 0; public: Converter(double ratio) { this->ratio = ratio; } void run() { double src; cout
1 #include #include using namespace std; class Circle { int radius; public: Circle(int radius = 0) { this->radius = radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } double getArea() { return 3.14 * radius * radius; } }; class NamedCircle : public Circle { string name; public: NamedCircle(int radius=0, string name=" ") : Circle(radius) { this->nam..
1번 #include using namespace std; #include class Book { string title; int price, pages; public: Book(string title = "", int price = 0, int pages = 0) { this->title = title; this->price = price; this->pages = pages; } void show() { cout
전위연산자는 참조매개변수를 써서 값을 바로 바꿔준다 #include using namespace std; #include class Power { int kick; int punch; public: Power(int kick = 0, int punch = 0) { this->kick = kick; this->punch = punch; } void show(); friend Power& operator++(Power& op); friend Power operator++(Power& op, int x); }; void Power::show() { cout
보호되어 있는 글입니다.
보호되어 있는 글입니다.
보호되어 있는 글입니다.