Hi,
I have class which has two bool vectors:
typedef vector<bool> my_bool_vector;
class MyClass{
private:
my_bool_vector bvec;
my_bool_vector another_bvec;
public:
explicit MyClass(unsigned int size) :
bvec(size, false),
another_bvec(size, false) {
}
};
MyClass MyObject (10);
I want to be able to access bvec and another_bvec in the following way, using operator [] :
When I read MyObject[n], it should read bvec[n], and when I write to MyObject[n], it should write to another_bvec[n].
Is this even possible by overloading operator []? I have tried writing two versions, one that returns bool& and another that returns const bool, but g++ complains.
If this is not possible with operator [], can someone think of another efficient way?
My other option is use read(n)/write(n) interface functions, but they are cumbersome.
Thanks.