开发者

C++ general question

开发者 https://www.devze.com 2023-03-29 11:20 出处:网络
Miner::Miner(int id):BaseGameEntity(id), m_Location(shack), m_iGoldCarried(0), m_iMoneyInBank(0), m_iThirst(0),
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

精彩评论

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

关注公众号