Guest User

Untitled

a guest
Oct 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #ifndef COLORPOINT_CPP
  2. #define COLORPOINT_CPP
  3.  
  4. #include <iostream>
  5. #include "point.cpp"
  6.  
  7. using namespace std;
  8.  
  9. class ColorPoint : public Point {
  10.     private:
  11.     Point a;
  12.     string color;
  13.    
  14.     public:
  15.     ColorPoint() : a(Point()), color("colorless") {}
  16.    
  17.     ColorPoint( Point a, string color) : Point a(a), color(color){}
  18.    
  19.     bool operator==(const ColorPoint& other) const {
  20.             return a == other.a && color == other.color;
  21.         }
  22. };
  23. #endif
  24.  
  25. int main() {
  26.     ColorPoint a(5,9, "red");
  27.     ColorPoint b(5,9,"red");
  28.    
  29.     if (a == b){
  30.         cout << "Points are equal" << endl;
  31.     } else {
  32.         cout << "Points are not equal" << endl;
  33.     };
  34.  
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment