0
#include "stdafx.h"
#include <iostream>
using namespace std;
class S
{
public:
S()
{
}
S& operator=(S&)
{
std::cout << "copy assignment" << std::endl;
return *this;
}
};
int main()
{
S s;
s = S(); // passando um rvalue como argumento para uma função
// (copy assignment) que só aceita lvalue
getchar();
return 0;
}
Would anyone care to explain to me why copy assignment is called in this case? as far as I know, this should only compile if the copy assignment parameter is const S& where it would be possible to pass an rvalue..
Thanks, this is not the first 'anomaly' that I see in the visual c++.
– Strawberry Swing
@Strawberryswing if this answer can satisfactorily solve your question, you can mark it as accepted by clicking . This is the biggest thanks you can do
– Jefferson Quesado