int operator &( BMap24b a, BMap24b b );
bool operator &( BMap24b a, BMap24b b );
There is no way for the compiler to differentiate between the parameters of the two prototypes listed above. Therefore you have to do it somehow in your code. Then when you have determined how to tell when to return an int and when to return a bool you can make that happen, in a sense anyway.
If you want to be able to return one of two different types I would use a struct as a return type. The struct to have both possibities as data members.
Code:
struct Answer
{
int counter;
bool flag;
};
class whatever
{
//other stuff
Answer operator &( BMap24b a, BMap24b b );
};
Answer operator &( BMap24b a, BMap24b b )
{
Answer answer;
//determine whether you are going to initialize counter or flag
//do the manipulation
//change the value of counter or flag
return answer;
}
I suppose you could try using a union insetead of a struct, but I haven't used that construct at all in code that I've written.
Also: I have a problem with the following code:
Code:
bool BMap24b:: operator&( BMap24b a, BMap24b b )
{
bool flag;
int i;
i = a & b;
you are using the & operator with types for which you are trying to define the & operator. That seems illogical to me.