code:<HR>Code:class Monkey { public: int eyes;<P> Monkey(); Monkey(int eyes); };
Now with that header definition why would someone set up their constructors like...
code:<HR>Code:Monkey::Monkey() : eyes(2) { }<P>Monkey::Monkey(int e) : eyes(e) { }
instead of...
code:<HR>Code:Monkey::Monkey() { eyes = 2; }<P>Monkey::Monkey(int e) { eyes = e; }
??? Sure, I guess you can save a line, but it starts to get hard to read if you initalize a bunch of variables like so...
code:<HR>Code:Monkey::Monkey(int eyes, int ears, int toes) : eyes(eyes), ears(ears), toes(toes) { }
The only thing I can think of is to make something like so clear...
code:<HR>Code:Monkey::Monkey(int eyes, int ears, int toes) : eyes(eyes), ears(ears) { this->toes = 6; }
Thanks.
~Kevin