how to create a good operator
Well this is my problem.
I am implementing a class that should act like an array of data.
meaning that it should have a operator.
the problem is that my class may not hold the values in the array.
like a bitArray class for example. (when needed it actually constracts the bit requested)
I want to be able to write the code:
bitArray &ba = new bitArray(100);
ba = 1;
in the case of huffman code and i want to get the 9'th byte in the compressed data
HuffmanCode &hc = new HuffmanCode(File *src);
x = hc;
and so on.
So what should operator return?
I can't return some class Element since Element will need to know about the bitArray
and bitArray will need to know about Element
making it impossible to compile.
what should i do?
how do i implement it the way that i can use the sample code above.
thanks a lot for any help.