Pointers are "POD types" ... aka "Plain old data." Here are the rules for when and where they are initialized by default:
Initializing Default POD Types in C ++
So no. It doesn't matter what your constructor is for a class if it is a raw pointer as a member of the class. You are not actually instantiating the class. That way, members like Foo * or std::vector<Foo> * or anything that ends with * will not be initialized to nullptr.
Smart pointer classes are not PODs. Therefore, if you use unique_ptr<Foo> or shared_ptr<Foo> , which creates instances of classes that have a constructor, which makes them effectively null if you do not initialize them.
Does it matter if I do MyCLass * o = new MyCLass; or am I doing MyCLass * o = new MyCLass (); in c ++ 11?
One question per question, please.
Are parentheses made after the type name with a new one?
source share