fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class ID_Record
  5. {
  6. public:
  7. unsigned int id; // Record ID used for database.
  8. std::string value;
  9. };
  10.  
  11. int main() {
  12. ID_Record a{6, "Tree"};
  13. ID_Record b{3, "Platinum"};
  14. if (a == b) std::cout << "Records are equal\n"; // This line should fail compilation.
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:14:8: error: no match for ‘operator==’ (operand types are ‘ID_Record’ and ‘ID_Record’)
  if (a == b) std::cout << "Records are equal\n"; // This line should fail compilation.
      ~~^~~~
stdout
Standard output is empty