Bool returning value 204

Apr 20, 2014 at 6:59pm
I have a class that uses a Bool to store something. I have a member function that returns the value of that Bool. It wasn't working as expected so I tried printing the value of the Bool returned by the member function and I got 204.

What.might cause something like this?
Last edited on Apr 20, 2014 at 7:02pm
Apr 20, 2014 at 7:11pm
closed account (z0My6Up4)
It means the bool value is non zero hence, true
Apr 20, 2014 at 7:28pm
When you say "Bool" do you mean something different from the C++ built in bool type? And how are you printing the value? It might help if you shared the relevant parts of your code.

Normally a bool will print as 1 or 0, or possibly as "true" or "false" if you use std::cout << std::boolalpha;
1
2
3
4
5
    bool a;
    a = 204;
    std::cout << "a is " << a << std::endl;
    std::cout << std::boolalpha;
    std::cout << "a is " << a << std::endl;

Output:
a is 1
a is true
Last edited on Apr 20, 2014 at 7:30pm
Topic archived. No new replies allowed.