A
Alex Vinokur
Compiler GNU gpp.exe (GCC) 3.4.1
Foo(300) = Foo(500); // Foo(300) is const. Why does a compiler compile that?
------ foo.cpp ------
struct Foo
{
explicit Foo(int) {}
Foo& operator= (const Foo&)
{
return *this;
}
};
int main()
{
Foo var1(100);
const Foo var2(200);
var1 = Foo(500);
Foo(300) = Foo(500); // Foo(300) is const. Why does a compiler compile that?
// var2 = Foo(500); // A compiler doesn't compile that
return 0;
}
Foo(300) = Foo(500); // Foo(300) is const. Why does a compiler compile that?
------ foo.cpp ------
struct Foo
{
explicit Foo(int) {}
Foo& operator= (const Foo&)
{
return *this;
}
};
int main()
{
Foo var1(100);
const Foo var2(200);
var1 = Foo(500);
Foo(300) = Foo(500); // Foo(300) is const. Why does a compiler compile that?
// var2 = Foo(500); // A compiler doesn't compile that
return 0;
}