Constructors

Hi there

Constructors in such a format
1
2
 matrix(int employee_, std::string name_, std::string surname_, double rate_) : employee(employee_), name(name_), surname(surname), rate(rate_)
	{}


is this C++98 format?
Do you need still write with : and repeat variables?

thanks :)
yes it is C++98 format, and yes, if you want to say that the member called "employee" needs to be initialized from the first argument of the constructor, there should be "employee(x)" or "employee{x}" appearing after the colon, where "x" is the name of that first argument: see http://en.cppreference.com/w/cpp/language/initializer_list
Last edited on
HI Cubbi

thank you for this,
How would constructor look in modern C++?(14 or 17?)

thanks :)
Same way, except curly braces are now an option, : employee{employee_}, ... instead of : employee(employee), ...
Last edited on
thanks Cubbi :)
Topic archived. No new replies allowed.