#include <iostream>
class Foo
{
private :
int m_data;
public :
Foo( int data)
: m_data( data)
{
}
void operator= ( const Foo& other)
{
m_data = other.m_data ;
}
int GetData( )
{
return m_data;
}
} ;
int main( )
{
auto a = Foo( 42 ) ;
auto b = Foo( 24 ) ;
auto c = Foo( 10 ) ;
a = b = c;
std:: cout << & a << ": " << a.GetData ( ) << std:: endl ;
std:: cout << & b << ": " << b.GetData ( ) << std:: endl ;
std:: cout << & c << ": " << c.GetData ( ) << std:: endl ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgRm9vCnsKcHJpdmF0ZToKCWludCBtX2RhdGE7CgkKcHVibGljOgoJRm9vKGludCBkYXRhKQoJOiBtX2RhdGEoZGF0YSkKCXsKCQkKCX0KCgl2b2lkIG9wZXJhdG9yPShjb25zdCBGb28mIG90aGVyKQoJewoJCW1fZGF0YSA9IG90aGVyLm1fZGF0YTsKCX0KCQoJaW50IEdldERhdGEoKQoJewoJCXJldHVybiBtX2RhdGE7Cgl9Cn07CgppbnQgbWFpbigpIAp7CglhdXRvIGEgPSBGb28oNDIpOwoJYXV0byBiID0gRm9vKDI0KTsKCWF1dG8gYyA9IEZvbygxMCk7CgkKCWEgPSBiID0gYzsKCQoJc3RkOjpjb3V0IDw8ICZhIDw8ICI6ICIgPDwgYS5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICZiIDw8ICI6ICIgPDwgYi5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICZjIDw8ICI6ICIgPDwgYy5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJCglyZXR1cm4gMDsKfQ==
compilation info
prog.cpp: In function 'int main()':
prog.cpp:32:4: error: no match for 'operator=' (operand types are 'Foo' and 'void')
a = b = c;
^
prog.cpp:15:7: note: candidate: void Foo::operator=(const Foo&)
void operator=(const Foo& other)
^
prog.cpp:15:7: note: no known conversion for argument 1 from 'void' to 'const Foo&'
stdout