In the following code:
class SomeClass {
vector<int> i;
vector<bool> b;
public:
int& geti() {return i[0];}
bool& getb() {return b[0];}
};
If you comment out getb()
, the code compiles fine. Apparently there's no problem returning a reference to an int
that's stored in a vector, but you can't do it with a bool
.
Why is this?