Advertisement
Guest User

Simple Equality

a guest
Aug 4th, 2011
769
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class Test
  7. {
  8. public:
  9.     std::string Name;
  10.     Test::Test(std::string name) : Name(name) {}
  11.     std::string operator==(const Test& other) {
  12.         if(this->Name == other.Name) return "Equal!";
  13.         return "Not equal!";
  14.     }
  15. };
  16.  
  17. int _tmain(int argc, wchar_t* argv[])
  18. {
  19.     Test a = Test("USA");
  20.     Test b = Test("Canada");
  21.     cout << (a == b) << "\n";
  22.     b.Name = "USA";
  23.     cout << (a == b) << "\n";
  24.     return 0;
  25. }
Advertisement
RAW Paste Data Copied
Advertisement