Is there a way in C++ to deal with this? (a way to force that a boolean is strictly a boolean and cannot be converted to another numerical type?)

line 42: Error: Overloading ambiguity between "MultiLog::writeLog(const long&)" and "MultiLog::writeLog(const bool&)"

you might have some other problem. This works ok for me

#include <iostream>
using namespace std;

void foo(const long& l)
{
	cout << l << endl;
}

void foo(const bool& l)
{
	cout << l << endl;

}


int main(int argc, char* argv[])
{
	bool b = true;
	foo(b);
	return 0;
}

What about if you pass a long to the function in main?

What about if you pass a long to the function in main?

no problem with that either. why don't you post your program (zip it up first if its pretty long)

I figured it out. When I pass an int, it can't decide whether to use the bool or the long. I think I just need to create an int version of the function as well...

or you can cast your int to long or bool...

or use a template?? I'm not very good at them, so don't ask me how.

or use a template?? I'm not very good at them, so don't ask me how.

I could use a template or do the cast, the problem is that I want to do special processing based on the type (ie if it's a bool, then print it out as 'TRUE' or 'FALSE', etc. By adding the function for int, it worked out fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.