In this code- #include <iostream>
The value of d is always 0, and the 'std::cout<<a' code gives no output. Why? Please help!
Thanks, it works. But what confusing me is that, in my wrong method, if I enter a string, say "abcd" and we compare it with another string b(std::string b="abcd") by->a==b, i am actually getting a return value-0, which means that the strings are same. But as I said, when I am printing a i get nothing. How is that happening?
The return value of operator == has type bool. It is true when they are equal and it is false when they are not equal. If you convert bool to int (such as by printing it without boolalpha), false becomes 0 and true becomes 1. This is the same in any compiler.