Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello.
what is the role of ":" and "," on this function?
VB
GameTime(const log & c, const log & s) : M_cycle(c), M_stopped(s)

Thanks.
Posted
Updated 23-Nov-11 9:02am
v3

They are simply syntax tokens of the C++ constructor initializer list, see, for instance: "Initializing base classes and members"[^].
 
Share this answer
 
Comments
Albert Holguin 22-Nov-11 10:47am    
that's it... +5
CPallini 22-Nov-11 13:33pm    
Thank you.
Sergey Alexandrovich Kryukov 22-Nov-11 17:20pm    
Correct, and yes, not related to multiple inheritance. My 5.
--SA
CPallini 23-Nov-11 3:59am    
Thanks.
elgaabeb 23-Nov-11 10:03am    
all about it ... 5'd.
Multiple inheritance
In C++ it is perfectly possible that a class inherits members from more than one class. This is done by simply separating the different base classes with commas in the derived class declaration. For example, if we had a specific class to print on screen (COutput) and we wanted our classes CRectangle and CTriangle to also inherit its members in addition to those of CPolygon we could write:

VB
class CRectangle: public CPolygon, public COutput;
class CTriangle: public CPolygon, public COutput;


"quoted from outside source"

So ,

":" means that GameTime inherits M_cycle and (",") M_stopped ...

P.S. What does US flag in Your profile means ??? Just out of curiosity ...

Edit : Solution 1 is probably what You are after, as I was thinkin of classes and You stated clearly it was the function ..
 
Share this answer
 
v2
Comments
Albert Holguin 22-Nov-11 10:47am    
What does the US flag mean? ...means he's indicated that he's located in the US... have you looked at your profile? You have a flag as well...
CPallini 22-Nov-11 13:35pm    
Well, there is no multiple inheritance in the code posted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900