composition | Sololearn: Learn to code for FREE!



I'm learning about composition and I noticed that if you do not use contructor initializer list to assign values to the object, it does not work... why is this? (without initializer list) (with initializer list)


1/1/2022 3:27:41 PM

Sheldon 10110

1 Answer

New Answer


It is because in C++ if you only define a constructor with parameters you must always intilialize it with paremeters. You have to overload the constructor to the eye class and add one that takes no parameters for it to work.