I have made the following code:-
class A{
bool bFlag[2];
public:
A(){
for(int i = 0; i < 2; i++)
bFlag[i] = false;
}
bool operator[](int r){ //i know how to assign value to R.H.S using operator[]
if( r >= 0 || r < 2 ){
bFlag[r] = true;
return bFlag[r];
}
return false;
}
};
int main(){
A obj;
bool x;
x = obj[0]; //this i know
//obj[1] = x; //how to do this is my doubt?
return 0;
}
I dont know to set value to L.H.S using operator[].
Please guide me to how to set x value to obj[1]
Als is right, but here is an example:
this makes in posible to do things like
you should of course add the old method as well. to optimize for l-value to making it.