I'm having trouble getting the following operator to overload. I want to take two inputs of type BMap24b and get either an int or a bool, depending on the recieving tupe. Any help would be appreciated.

Code:
```public:
int operator &( BMap24b a, BMap24b b );
bool operator &( BMap24b a, BMap24b b );

int BMap24b:: operator&(BMap24b a, BMap24b b)
{
int counter = 0;

if( a.Color[0].i == b.Color[0].i )
{
counter += 0;
}
else {
if( a.Color[0].i > b.Color[0].i )
{
counter -= 1;
}
else {
counter += 1;
}
}

if( a.Color[1].i == b.Color[1].i )
{
counter += 0;
}
else {
if( a.Color[1].i > b.Color[1].i )
{
counter -= 1;
}
else {
counter += 1;
}
}

if( a.Color[2].i == b.Color[2].i )
{
counter += 0;
}
else {
if( a.Color[2].i > b.Color[2].i )
{
counter -= 1;
}
else {
counter += 1;
}
}

return( counter );
}

bool BMap24b:: operator&( BMap24b a, BMap24b b )
{
bool flag;
int i;

i = a & b;
if( i == 0 )
{
flag = 1;
} else {
flag = 0;
}

return( flag );
}```

In the same program I have two Global CStrings, SrcFile and TrgtFile, I can't figure out how to write to them from a class that has the file with them included. Once again, any help would be appreciated.

2. 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 )
{
//determine whether you are going to initialize counter or flag
//do the manipulation
//change the value of counter or flag
}```
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.

3. The use of & that you mentioned was an attempt at saving code. I'll try that union idea, it should work. I'm actually using unions in the BMap24b class.

Still looking for an explanation of the global CString problem.

New code :
Code:
```public:
Bool_Int operator&( BMap24b a, BMap24b b );```
I'm getting a error saying:

Code:
`error C2804: binary 'operator &' has too many parameters`

4. I'm getting a error saying:

error C2804: binary 'operator &' has too many parameters

Well as far as error messages go, that's as clear as it gets. You say its a global function, yet the code shows it to be a class function. It's a "binary" operator so there can only be two arguments. You have the object on the left hand side for which the operator is called on and then two parameters on the right:

object_lhs & (object_a) object_b???

That's 3 objects.

5. Thanks, and the CStrings are Globals, not the function. Must not have made that clear enough.