All the tutorials I have watched & read on objected oriented programming in C++ tell me to use default constructors in order to initialize all the member variables of a class to their null state. But from a book i'm also learning from, it has an example (which i have also tested and it works) of a class without a default constructor which leads me to question why are default constructors necessary?
// this class does not have a default constructor!
B() // the default constructor (default means no-params)
myValue = 0;
B(int initialValue) // here is an "explicit constructor" example
myValue = initialValue;
std::cout << "A's value: " << myClassA.myValue << std::endl;
std::cout << "B's value: " << myClassB.myValue << std::endl;
If you were to compile this, and run it; I have no idea what would appear on the first line, but I know for sure that the 2nd line will display the number '0'.
so as you stated:
"use default constructors in order to initialize all the member variables of a class to their null state"
maybe replace the word "null" with default when you read that.