开发者

C++ general question

Miner::Miner(int id):BaseGameEntity(id),
                     m_Location(shack),
                     m_iGoldCarried(0),
                     m_iMoneyInBank(0),
                     m_iThirst(0),
                     m_iFatigue(0),
                     m开发者_如何学运维_pCurrentState(GoHomeAndSleepTilRested::Instance())

What exactly does this mean? It is declared under the class:

class Miner : public BaseGameEntity

btw... when ever I try to code blocks my code in this sight tab gets me out of this window :s how am I meant to?


It is the constructor of Miner class, using initialization list.

Refer to the following link for details of initialization list: http://www.cprogramming.com/tutorial/initialization-lists-c++.html


It is a constructor definition with ctor-initializer.


That's an initializer list - it instructs the compiler to initialize member variables to that values and call a specific constructor of the base class with passing it a specific value.


This is the implementation of the constructor. Furthermore he assigns values to the class members: m_Location, etc.. and calls the base class constructor.


It's the beginning of a constructor, and it is initalising the class members and base class. This is basic C++ syntax and should all be explained any C++ book.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜