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