fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct mystring {
  5. mystring(const char* str) {
  6. cout << "Constructed '" << str << "'" << endl;
  7. }
  8. __attribute__((warn_unused_result))
  9. bool operator==(const mystring& other) const {
  10. cout << "Compared" << endl;
  11. return false;
  12. }
  13. };
  14.  
  15. int main() {
  16. mystring a("hello");
  17. a == "world";
  18. return 0
  19. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:1: error: expected ‘;’ before ‘}’ token
 }
 ^
prog.cpp:17:14: warning: ignoring return value of ‘bool mystring::operator==(const mystring&) const’, declared with attribute warn_unused_result [-Wunused-result]
  a == "world";
              ^
stdout
Standard output is empty