#include <iostream>
using namespace std;
struct mystring {
mystring( const char * str) {
cout << "Constructed '" << str << "'" << endl;
}
__attribute__( ( warn_unused_result) )
bool operator== ( const mystring& other) const {
cout << "Compared" << endl;
return false ;
}
} ;
int main( ) {
mystring a( "hello" ) ;
a == "world" ;
return 0
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IG15c3RyaW5nIHsKICAgIG15c3RyaW5nKGNvbnN0IGNoYXIqIHN0cikgewogICAgICAgIGNvdXQgPDwgIkNvbnN0cnVjdGVkICciIDw8IHN0ciA8PCAiJyIgPDwgZW5kbDsKICAgIH0KICAgIF9fYXR0cmlidXRlX18oKHdhcm5fdW51c2VkX3Jlc3VsdCkpCiAgICBib29sIG9wZXJhdG9yPT0oY29uc3QgbXlzdHJpbmcmIG90aGVyKSBjb25zdCB7CiAgICAgICAgY291dCA8PCAiQ29tcGFyZWQiIDw8IGVuZGw7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQp9OwoKaW50IG1haW4oKSB7CglteXN0cmluZyBhKCJoZWxsbyIpOwoJYSA9PSAid29ybGQiOwoJcmV0dXJuIDAKfQ==
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