C++, MFC, sanity, insanity
One of the really nice things about C++ compared with C is the existence of constructors. In C, if you say:
struct { int count; } thing;
then thing.count holds a random value until you set it to something. In C++, that doesn’t happen because any sane class has a constructor that sets the member variables to sensible default values:
class Thing { Thing(void) { count = 0; } int count; };
You can’t create a Thing with a random count because the constructor gets called automatically.
MFC is Microsoft’s C++ framework for Windows development. It’s very widely used, mature and stable. It has a class CRect to represent a rectangle. And does its default constructor set the coordinates to sensible default values? Does it hell. Does it even set them to known insane values, to immediately alert you when you forget to initialise them, or when you naturally assume that the default constructor is sane? Does it hell.
Thank you whoever at Microsoft made that decision. You just cost me about 6 hours of my life.