The problem with malloc and free: they don’t know about constructors and destructors
Item 2: Prefer to
Advantage of iostream: type safety
iostream vs iostream.h: isostream has its own namespace.
Item 19: Differentiate Among Member Functions, Non-member Functions, and Friend Functions
Summary:
Virtual functions must be members. If f needs to be virtual, make it a member function of C.
operator>> and operator<< are never members. If f is operator» or operator«, make f a non-member function. If, in addition, f needs access to non-public members of C, make f a friend of C.
Only non-member functions get type conversions on their left-most argument. If f needs type conversions on its left-most argument, make f a non-member function. If, in addition, f needs access to non-public members of C, make f a friend of C.
Everything else should be a member function. If none of the other cases apply, make f a member function of C.
Item 1: Prefer Const and Inline to #define
Classic example of why sometimes macro is a bad idea:
The _explicit_ Keyword in C++ Is Used to Declare Explicit Constructors. Explicit Constructors Are Constructors That Cannot Take Part in an Implicit Conversion
The explicit keyword in C++ is used to declare explicit constructors. Explicit constructors are constructors that cannot take part in an implicit conversion