在 c++ 中调用基本构造函数命令行界面
如果我从基类继承并希望将某些内容从继承类的构造函数传递给基类的构造函数,我该怎么做?
例如,
如果我继承 Exception 类,我想做这样的事情:
在 C# 语言中,我们这样做:
public class CppDynamicSyntaxLanguage : DynamicOutliningSyntaxLanguage
{
public CppDynamicSyntaxLanguage(string key, bool secure) :
**base(key, secure)** {}
}
但在 c++.net 中如何做到这一点? 我尝试这样做:
public ref class CppDynamicSyntaxLanguage : public DynamicOutliningSyntaxLanguage
{
public:
CppDynamicSyntaxLanguage (String ^key, bool secure) :
**CppDynamicSyntaxLanguage(key,secure)** {};
}
但我得到了 错误 'MyEditor::CppDynamicSyntaxLanguage':非法成员初始化:'CppDynamicSyntaxLanguage'不是基础或成员
“谢谢”
If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?
For example,
If I inherit from the Exception class I want to do something like this:
in C# Language we do it like this:
public class CppDynamicSyntaxLanguage : DynamicOutliningSyntaxLanguage
{
public CppDynamicSyntaxLanguage(string key, bool secure) :
**base(key, secure)** {}
}
but how to do it in c++.net ?
i try to do it like this :
public ref class CppDynamicSyntaxLanguage : public DynamicOutliningSyntaxLanguage
{
public:
CppDynamicSyntaxLanguage (String ^key, bool secure) :
**CppDynamicSyntaxLanguage(key,secure)** {};
}
but i got
Error
'MyEditor::CppDynamicSyntaxLanguage' : illegal member initialization: 'CppDynamicSyntaxLanguage' is not a base or member
"Thank You"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基类名为
DynamicOutlinedSyntaxLanguage
,而不是CppDynamicSyntaxLanguage
。The base class is named
DynamicOutliningSyntaxLanguage
, notCppDynamicSyntaxLanguage
.你尝试过吗:
它可以在c++中工作,不知道.net。假设 DynamicOutlinedSyntaxLanguage 有一个使用 sting 和 bool 的构造函数。
Did you try:
It would work in c++, don't know about .net. Assuming DynamicOutliningSyntaxLanguage has a constructor that consumes sting and bool.