#include #include using namespace std; class Point { int x, y; public: void set(int x, int y) { this->x = x; this->y = y; } void showPoint() { cout
#include using namespace std; 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); Power operator++ (int x); }; void Power::show() { cout
#include using namespace std; class Power { int kick; int punch; public: Power(int kick = 0, int punch = 0) { this->kick = kick; this->punch = punch; } Power operator+ (Power op2); Power& operator+=(Power op2); Power operator + (int op2); bool operator==(Power op2); Power& operator++(); Power operator++(int x); bool operator!(); void show(); }; Power Power::operator+(Power op2) { Power tmp; tmp...
#include #include using namespace std; class Book { string title; int price = 0; public: Book(string title, int price) { this->title = title; this->price = price; } ~Book() {}; void set(string title, int price) { this->title = title; this->price = price; } void show() { cout
#include using namespace std; void fillLine(int n = 25, char c = '*') { // n개의 c 문자를 한 라인에 출력 for (int i = 0; i < n; i++) cout
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; class Person { // Person 클래스 선언 char* name; int id; public: Person(int id, const char* name); // 생성자 Person(const Person& person); // 복사 생성자 ~Person(); // 소멸자 void changeName(const char* name); void show() { cout id = person.id; // id 값 복사 int len = strlen(person.name);// name의 문자 개수 this->name = new char[len + 1]; // name을 위..
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; class Person { // Person 클래스 선언 char* name; int id; public: Person(int id, const char* name); // 생성자 ~Person(); // 소멸자 void changeName(const char* name); void show() { cout name) delete[] this->name; int len = strlen(name); this->name = new char[len + 1]; strcpy(this->name, name); } int main() { Person father(1, "Kitae");// (..
#include using namespace std; char& find(char a[], char c, bool& success); int main() { cout
#include using namespace std; void increaseBy(Circle& a, Circle b); class Circle { private: int radius; public: Circle(int r) { radius = r; } int getRadius() { return radius; } void setRadius(int r) { radius = r; } void show() { cout
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; class Book { private: double price; int pages; char* title; char* author; public: Book(double price, int pages, const char* title, const char* author); ~Book(); void changeTitle(const char* title); void show(); }; Book::Book(double price, int pages, const char* title, const char* author) { this->price = price; this->pages = p..
#include using namespace std; class Circle { private: int radius; public: Circle(const Circle& c); // 복사 생성자 선언 Circle() { radius = 1; } Circle(int radius) { this->radius = radius; } double getArea() { return 3.14 * radius * radius; } }; Circle::Circle(const Circle& c) { // 복사 생성자 구현 this->radius = c.radius; cout
#include using namespace std; bool average(int a[], int size, int* avg); int main() { int x[] = { 0, 1, 2, 3, 4, 5 }; int avg; if (average(x, 6, &avg)) cout
#include using namespace std; int main() { cout
#include using namespace std; class Circle { int radius; public: Circle() { radius = 1; } Circle(int radius) { this->radius = radius; } void setRadius(int radius) { this->radius = radius; } double getArea() { return 3.14 * radius * radius; } }; Circle getCircle() { Circle tmp(30); return tmp; } int main() { Circle c; cout
# 값에 의한 호출 #include using namespace std; class Circle { private: int radius; public: Circle(); Circle(int r); ~Circle(); double getArea() { return 3.14 * radius * radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } }; Circle::Circle() { radius = 1; cout