Hi!

What happens if you have an object my_obj of class my_class, and you write:

Code:
if (my_obj) {...} else {...}
How do you know which code block that is executed? The first or the second? Can you make my_class decide what value an object of that type should have when it is looked at as a boolean variable (here true can be any value other than 0 so it doesn't have to be of the type bool)?

For example, I have a class which is basically a kind of wrapper class for a variable v (it contains some other stuff too). When I write if(obj) I want it to be the same as if I would have written if(obj.v).

Thanks in advance!