Assignment operator inheritance

Actually, what is called is the implicitly defined operator = for Derived. The definition provided by the compiler in turn calls operator = for the Base and you see the corresponding output. The same is with the constructor and destructor. When you leave it to the compiler to define operator =, it defines it as … Read more

Why doesn’t ToUpper() return “*” when applied to “8”?

No, it shouldn’t. ToUpper() doesn’t mean WithShiftKeyOnAnInternationalASCIIKeyboard(). There isn’t an uppercase 8, as 8 is a number, not a letter. Of course, this is a gross over-simplification (being a number alone doesn’t automatically make a certain character in a character set caseless), but it’s likely what you’re asking for anyway so I’ll leave it at … Read more

Keep only numeric value from a string?

You do any of the following: Use regular expressions. You can use a regular expression with either A negative character class that defines the characters that are what you don’t want (those characters other than decimal digits): private static readonly Regex rxNonDigits = new Regex( @”[^\d]+”); In which case, you can do take either of … Read more

C++ const in getter [duplicate]

There is a huge difference between the two ways. const bool isReady() The code above will return a const bool, but it does not guarantee that the object will not change its logic state. bool isReady() const This will return a bool, and it guarantees that the logic state of your object will not change. … Read more