boolean function parameter always true

Hello,

I got a member function which just got one parameter (a boolean) as follows:

1
2
3
4
5
class CConnection
{
//stuff
Inc::STATS EnableAutoMode(bool b);
};

1
2
3
4
5
Inc::STATS CConnection::EnableAutoMode(bool b = true)
{
	if(b == true)
	{
//and so on... 


and when i call it like this:
1
2
//Disable auto mode
	m_pConnection->EnableAutoMode(false);


It ALWAYS handles b as true... What the heck is going on??????
When i remove the default parameter ( = true) it is still the same...

im desperate-.-'...

Anyone may realize my mistake?...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class CConnection
{
//stuff
Inc::STATS EnableAutoMode(bool b = true); //default parameter value should be here 
};


.........

Inc::STATS CConnection::EnableAutoMode(bool b)
{
	if(b == true)
	{
//and so on...  
doesn´t change anything...
try to use
if(b)
instead of
if(b == true)
Last edited on
Theres no mistake in this code, youll have to post the rest.

Also you could try to add some kind of debugging code to see what happens to bool b throughout the code
Last edited on
I suspect that the OP typed incorrectly into the forum. Always copy and paste. Don't try to retype the snips of code since you might end up writing the correct code even though the original code is still wrong.

Look at original code. is it this? if(b = true) or is it this? if(b == true)

In general, always post a complete example and copy and paste from your original. I could be wrong but I am just taking an educated guess here.
Topic archived. No new replies allowed.