Bool returning value 204

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
closed account (z0My6Up4)
It means the bool value is non zero hence, true
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
Topic archived. No new replies allowed.