I am going through Chapter 17 in the new Stroustrup book and I am confused by initializing a class with an initialization list.
Example:
in .hpp:
class A
{
public:
A() : _plantName(std::string s), _growTimeMinutes(int 1);
virtual ~A();
private:
std::string _plantName;
int _growTimeMinutes;
};
in .cpp:
A::A() : _plantName(std::string s), _growTimeMinutes(int i)
{
}
or is it in .cpp:
A::A(std::string s, int i) : _plantName(std::string s), _growTimeMinutes(int i)
{
}
and calling that:
A a {"Carrot", 10};
I learned c++ back in 1998 and have only programmed in it off and on over the years until recently. How long ago did this stuff change? I know I could still do that the older way but I really want to learn new!