调用原始构造函数的继承类的构造函数的语法 [英] Syntax of constructors of inherited classes calling the original constructor

查看:95
本文介绍了调用原始构造函数的继承类的构造函数的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须开展一个相当大的项目,一群人写的和

根本没有有用的文档,我的C ++已经生锈了一点,

现在我偶然发现了一个类似于下面的构造函数

并且不知道如何处理它:)


inheritedClass :: inheritedClass([ ...一堆参数...])

:originalConstructor([...一堆参数......])

,m_cells(cells),m_srfcs( srfcs)

{

[...一些代码......]

}


现在我的问题是我不知道这个方法定义中逗号分隔的

参数(?)m_cells和m_srfcs是做什么的。

是否有人能够告诉我这种语法有什么用?


除了不知道这些参数是做什么的,我必须知道这个

两个类实例的使用(m_cells和m_srfcs是

2个类的实例)会调用它们的构造函数,因为在那种情况下我会需要修改
传递给他们的论点。


我只是测试一下,但项目太大了,而且我需要做太多的改变。在我可以进行测试之前,我会立即进行测试并检查它的运行时行为。


任何帮助表示赞赏:)


问候,


Lars Uffmann

I have to work on a rather big project that a bunch of people wrote and
that has no useful documentation at all, my C++ has rusted in a bit,
now I stumbled over a constructor that looks something like the below
and have no idea what to do with it :)

inheritedClass::inheritedClass ([...bunch of arguments...])
: originalConstructor ([...bunch of arguments...])
, m_cells(cells), m_srfcs(srfcs)
{
[... some code ...]
}

Now my problem is that I have no clue what the comma-separated
arguments(?) m_cells and m_srfcs do in this method definition. Is
anyone able to enlighten me what this syntax is good for?

Besides not knowing what those arguments do, I must know wether this
usage of the two class instances (m_cells and m_srfcs are instances of
2 classes) would call their constructor, because in that case I would
need to modify the argument passed to them.

I would simply test this, but the project is just too big and there are
too many changes that I have to do at once before I can do a test
compilation and check it''s runtime behaviour.

Any help is appreciated :)

Regards,

Lars Uffmann

推荐答案



lars.uffm ... @ rwth-aachen.de写道:

lars.uffm...@rwth-aachen.de wrote:
我必须开展一个相当大的项目,一群人写的和
没有有用的文档,我的C ++有点生锈,现在我偶然发现了一个类似于下面的构造函数
并且不知道如何处理它:)

inheritedClass :: inheritedClass([...一堆参数...])
:originalConstructor([...一堆参数...])
,m_cells(cells),m_srfcs(srfcs)
{
[..一些代码......]
}
现在我的问题是我不知道这个方法定义中逗号分隔的
参数(?)m_cells和m_srfcs是做什么的。是否有人能够告诉我这种语法有什么用处?

http: //www.parashift.com/c++-faq-lit....html#faq-10.6

除了不知道这些论点是做什么的,我必须知道这个
使用两个类实例(m_cells和m_srfcs是
2个类的实例)会调用它们的构造函数,因为在这种情况下我需要修改传递给它们的参数。
I have to work on a rather big project that a bunch of people wrote and
that has no useful documentation at all, my C++ has rusted in a bit,
now I stumbled over a constructor that looks something like the below
and have no idea what to do with it :)

inheritedClass::inheritedClass ([...bunch of arguments...])
: originalConstructor ([...bunch of arguments...])
, m_cells(cells), m_srfcs(srfcs)
{
[... some code ...]
}

Now my problem is that I have no clue what the comma-separated
arguments(?) m_cells and m_srfcs do in this method definition. Is
anyone able to enlighten me what this syntax is good for?
http://www.parashift.com/c++-faq-lit....html#faq-10.6
Besides not knowing what those arguments do, I must know wether this
usage of the two class instances (m_cells and m_srfcs are instances of
2 classes) would call their constructor, because in that case I would
need to modify the argument passed to them.




是的,该语法调用m_cells和m_srfcs的构造函数


Gavin Deane



Yes, that syntax calls the constructors for m_cells and m_srfcs

Gavin Deane


la ********** @ rwth-aachen.de 写道:
我必须处理一个人们写的一个相当大的项目,而且根本没有有用的文档,我的C ++已经生锈了一点,


我怀疑这是个好主意。你似乎没有资格获得这个。

现在我偶然发现了一个类似下面的构造函数
并且不知道如何处理它:)

inheritedClass :: inheritedClass([...一堆参数...])
:originalConstructor([...一堆参数...])
,m_cells(cells),m_srfcs( srfcs)
{
[...一些代码...]
}
现在我的问题是我不知道逗号分隔的是什么/> arguments(?)m_cells和m_srfcs在此方法定义中执行。是否有人能够告诉我这种语法有什么用处?


m_cells和m_srfcs是inheritedClass的成员变量。以上

使用值''cells''和'srfcs''初始化theese varibles。


这是一个非常基本的习语。你应该参考你的Stroustrup(章节

10.4.6)或你选择的其他教科书来阅读它。

除了不知道这些论点的作用外,我必须知道这两个类实例的使用(m_cells和m_srfcs是
2类的实例)会调用它们的构造函数,因为在这种情况下我需要修改传递给它们的参数。

我只是测试这个,但是项目太大了,在我做一个测试和/或编译之前,我必须立刻做太多的改动。检查它的运行时行为。


无需更改项目。只需创建一个非常小的沙箱项目

只需一个文件来探索这个成语的语法和行为。


Gabriel

任何帮助表示赞赏:)

问候,

Lars Uffmann
I have to work on a rather big project that a bunch of people wrote and
that has no useful documentation at all, my C++ has rusted in a bit,
I doubt that this is a good idea. You seem not to be qualified for this.
now I stumbled over a constructor that looks something like the below
and have no idea what to do with it :)

inheritedClass::inheritedClass ([...bunch of arguments...])
: originalConstructor ([...bunch of arguments...])
, m_cells(cells), m_srfcs(srfcs)
{
[... some code ...]
}

Now my problem is that I have no clue what the comma-separated
arguments(?) m_cells and m_srfcs do in this method definition. Is
anyone able to enlighten me what this syntax is good for?
m_cells and m_srfcs are members variables of inheritedClass. The above
initializes theese varibles with the values ''cells'' and ''srfcs''.

This is a very basic idiom. You should refer to your Stroustrup (chapter
10.4.6) or other textbook of your choice to read about it.
Besides not knowing what those arguments do, I must know wether this
usage of the two class instances (m_cells and m_srfcs are instances of
2 classes) would call their constructor, because in that case I would
need to modify the argument passed to them.

I would simply test this, but the project is just too big and there are
too many changes that I have to do at once before I can do a test
compilation and check it''s runtime behaviour.
No need to change the project. Just create a very small sandbox project
with just one file to explore the syntax and behaviour of this idiom.

Gabriel
Any help is appreciated :)

Regards,

Lars Uffmann



la ********** @ rwth-aachen.de 写道:


顺便说一下,我只是好奇:你在哪个学院工作?


Gabriel
la**********@rwth-aachen.de wrote:

Btw, I''m just curious: At which institute do you work?

Gabriel
我必须在一个人们写的一个相当大的项目上工作,而且根本没有任何有用的文档,我的C ++已经生锈了一下,现在我偶然发现了一个类似于下面的构造函数
并且不知道该怎么做:)

inheritedClass :: inheritedClass([...一堆参数...])
:originalConstructor([...一堆参数...])
,m_cells(单元格),m_srfcs(srfcs)
{
[...一些代码...]
}

现在我的问题是我不知道这个方法定义中逗号分隔的
参数(?)m_cells和m_srfcs是做什么的。是否有人能够告诉我这种语法有什么用处?

除了不知道这些参数做什么之外,我必须知道这两个类实例的使用情况(m_cells)和m_srfcs是
2个类的实例)会调用它们的构造函数,因为在这种情况下我会需要修改传递给它们的参数。

我只是测试一下,但是项目太大了,在我做一个测试编译并检查它的运行时行为之前,我必须立即做太多的更改。

任何帮助表示赞赏:)

问候,

Lars Uffmann
I have to work on a rather big project that a bunch of people wrote and
that has no useful documentation at all, my C++ has rusted in a bit,
now I stumbled over a constructor that looks something like the below
and have no idea what to do with it :)

inheritedClass::inheritedClass ([...bunch of arguments...])
: originalConstructor ([...bunch of arguments...])
, m_cells(cells), m_srfcs(srfcs)
{
[... some code ...]
}

Now my problem is that I have no clue what the comma-separated
arguments(?) m_cells and m_srfcs do in this method definition. Is
anyone able to enlighten me what this syntax is good for?

Besides not knowing what those arguments do, I must know wether this
usage of the two class instances (m_cells and m_srfcs are instances of
2 classes) would call their constructor, because in that case I would
need to modify the argument passed to them.

I would simply test this, but the project is just too big and there are
too many changes that I have to do at once before I can do a test
compilation and check it''s runtime behaviour.

Any help is appreciated :)

Regards,

Lars Uffmann



这篇关于调用原始构造函数的继承类的构造函数的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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