본문 바로가기

프로그램/C++ 1000제138

C++ 126제] 어서와! C++은 처음이지! CHAPTER 11. PROGRAMMING EXERCISE 1. p475 2) p475 출처 : 반크_반크 20년 백서 ● + 연산자를 중복 정의하여서 다음과 같은 연산이 가능하도록 하라. 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Point {    int x, y; public:    Point(int px = 0, int py = 0)    {       x = px; y = py;    } //생성자 함수    int getX() { return x; } //접근자    int getY() { return y; }    void setX(int px) { x = px; } //설정자    void setY(int py) { y = py; }    ~Point() {} //소멸자 함수 }; cla.. 2024. 12. 2.
C++ 125제] 어서와! C++은 처음이지! CHAPTER 11. PROGRAMMING EXERCISE 1. 1) p475 출처 : 반크_반크 20년 백서 ● 위의 프로그램을 컴파일할 수 있도록 생성자, 접근자, 설정자 등의 함수를 추가하라.참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Point {    int x, y; public:    Point(int px = 0, int py = 0)    {       x = px; y = py;    } //생성자 함수    int getX() { return x; } //접근자    int getY() { return y; }    void setX(int px) { x = px; } //설정자    void setY(int py) { y = py; }    ~Point() {} //소멸자 .. 2024. 11. 23.
C++ 124제] 어서와! C++은 처음이지! CHAPTER 10. PROGRAMMING EXERCISE 5. p435 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Time { private:    int hours;    int minutes; public:    Time() :hours(0), minutes(0) {}    Time(int h, int m) :hours(h), minutes(m) {}    void displayTime()    {       cout    }    Time& operator++()    {       ++minutes;       return *this;    }    void ProcessTime()    {       if (minutes > 59)       {.. 2024. 11. 18.
C++ 123제] 어서와! C++은 처음이지! CHAPTER 10. PROGRAMMING EXERCISE 4. p434 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Box { private:    double length;    double width;    double height;   static int count; public:    Box(int l = 0, int w = 0, int h = 0) :length(l), width(w), height(h) {}    double getVolume(void)    {       return length * width * height;    }    void printBox(Box box); }; int Box::count = 0; void Box::p.. 2024. 11. 18.
C++ 122제] 어서와! C++은 처음이지! CHAPTER 10. PROGRAMMING EXERCISE 3. p434 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Box { private:    double length;    double width;    double height; public:    Box(int l = 0, int w = 0, int h = 0) :length(l), width(w), height(h) {}    double getVolume(void)    {       return length * width * height;    }    void Print();    bool operator   {       return (length                      w.. 2024. 11. 18.
C++ 121제] 어서와! C++은 처음이지! CHAPTER 10. PROGRAMMING EXERCISE 2. p433 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Box { private:    double length;    double width;    double height; public:    Box(int l = 0, int w = 0, int h = 0) :length(l), width(w), height(h) {}    double getVolume(void)    {       return length * width * height;    }    void Print();    bool operator== (Box& box2)    {       return (length == box2.. 2024. 11. 18.
C++ 120제] 어서와! C++은 처음이지! CHAPTER 10. PROGRAMMING EXERCISE 1. p433 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Box { private:    double length;    double width;   double height; public:    Box(int l=0, int w=0, int h=0):length(l), width(w), height(h){}    double getVolume(void)    {       return length * width * height;    }    void Print();    Box operator +(const Box& box2); }; void Box::Print() {    cout    cou.. 2024. 11. 17.
C++ 119제] 어서와! C++은 처음이지! CHAPTER 09. PROGRAMMING EXERCISE 6. p395 출처 : 반크_반크 20년 백서 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Game { private:    string S;    static int count; public:    Game(string S) {       count++;       this -> S = S;       Show();    }    void Show()    {       cout S    }    ~Game() {       count--;    } }; int Game::count = 0; int main() {   //첫번째 플레이어 객체를 생성한다.   Game g1("One");   //두번째 플레이어 객체를 생성한다.  .. 2024. 11. 16.
C++ 118제] 어서와! C++은 처음이지! CHAPTER 09. PROGRAMMING EXERCISE 5. p395 출처 : 반크_백제역사 유적지구와 이스탐블 역사지구 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Box { private:    double length;    double width;    double height;    static int count; public:    Box(double l = 2.0, double w = 2.0, double h = 2.0) {       length = l;       width = w;       height = h;       count++;    }    double Volume() {       return length * width * height;    }    v.. 2024. 11. 11.
C++ 117제] 어서와! C++은 처음이지! CHAPTER 09. PROGRAMMING EXERCISE 4. p394 출처 : 반크_백제역사 유적지구와 이스탐블 역사지구 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  using namespace std; class Point { private:    double xval, yval; public:    Point(double x=0.0, double y=0.0)    {       xval = x; yval = y;    }    double getX() { return xval; }    double getY() { return yval; }    void Swap(Point& other1, Point& other2);    void Print(); }; void Point::Swap(Point &other1, Point &othe.. 2024. 11. 11.
C++ 116제] 어서와! C++은 처음이지! CHAPTER 09. PROGRAMMING EXERCISE 3. p394 출처 : 반크_백제역사 유적지구와 이스탐블 역사지구 참고풀이]#define _CRT_SECURE_NO_WARNINGS #include  #include  //strcpy() using namespace std; class MyClass { public:    MyClass(const char* str);    MyClass(const MyClass& other); //복사생성자를 선언한다.    void Show();    ~MyClass(); private:    char* stored;    char* Str; }; MyClass::MyClass(const char* str) {    stored = new char[strlen(str) + 1];    strcpy(stored, str); } MyC.. 2024. 11. 4.
C++ 115제] 인하대 과제4 출처 : 반크_백제역사 유전지구와 이스탐블 역사지구 참고풀이1] 하나의 객체 파일로 구현하기#define _CRT_SECURE_NO_WARNINGS #include  #include  #include #include  #include  //setw(), setfill() using namespace std; class Point { private:    int x, y;    char code[3];    char data[100]; public:    Point(int x = 0, int y = 0) : x(x), y(y) { };    int getX() { return x; }    int getY() { return y; }    bool operator==(const Point& p2)    {.. 2024. 10. 6.
반응형