I've just start with Beginning C++ Through Game Programming. I'm stuck on Chapter 8, with a section of syntax I don't understand. The line in question is
1 2 3 4 5
Critter::Critter(int hunger):
m_Hunger(hunger)
{
cout << "A new critter has been born!" << endl;
}
I understand that this is a constructor definition, and passes an int to the variable m_Hunger, but I don't understand the ':'. Is this shorthand of some sort?
In previous examples in the book, the constructor definition looked like:
1 2 3 4 5
Critter::Critter(int hunger) // constructor definition
{
cout << "A new critter has been born!" << endl;
m_Hunger = hunger;
}