的问题:和 [英] a Question of : and ,

查看:72
本文介绍了的问题:和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.
在此函数中:"和,"的作用是什么?

Hello.
what is the role of ":" and "," on this function?

GameTime(const log & c, const log & s) : M_cycle(c), M_stopped(s)


推荐答案

它们只是C ++ constructor initializer list的语法标记,例如,参见: [
They are simply syntax tokens of the C++ constructor initializer list, see, for instance: "Initializing base classes and members"[^].


多重继承
在C ++中,一个类完全有可能从多个类中继承成员.这是通过在派生类声明中简单地用逗号分隔不同的基类来完成的.例如,如果我们有一个要在屏幕上打印的特定类(COutput),并且我们希望我们的类CRectangle和CTriangle除了CPolygon的成员之外还继承其成员,我们可以这样写:

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:

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



从外部引用"

所以,

:" 表示GameTime继承了M_cycle和(," )M_stopped ...

P.S.您个人资料中的美国国旗是什么意思???只是出于好奇...

解决方案1可能是您所追求的,因为我在考虑类,并且您清楚地表明它是函数..



"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 ..


这篇关于的问题:和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆