This question already has an answer here:
I am a bit curious why my code prints a number instead of bool value.
class fb
{
public:
    bool p;
    void
    func()
    {
        memset(&(p), 4, 1);
    }
};
int
main()
{
    fb f;
    f.func();
    std::cout << f.p << std::endl;
    return 0;
}
My code prints number "4" and I am not really sure why this happens. Can you please explain me what is wrong with my code? I was expecting that result will be "true".
Thank you
Aucun commentaire:
Enregistrer un commentaire