This question already has an answer here:
With user defined conversion in C++ using the operator keyword, for example
class X {
private:
int _x;
public:
operator int() const { return _x; }
};
how does the const qualifier change anything vs. not have a const qualifier? It seems that regardless of having const or no const, I would still need to assign to an lvalue like this:
X x;
const int &foo = x;
Aucun commentaire:
Enregistrer un commentaire