g++ C++11 链式施工合规性

发布于 2024-12-15 13:23:11 字数 397 浏览 1 评论 0原文

我只是想知道 g++ 是否实际上符合链式构造函数(或任何名称)的 C++11 标准。

示例:

class MyClass
{
  MyClass(int x, int y = 0);
  MyClass(int y = 0) : MyClass(8, y) {}
};

即使我包含了 -std=c++0x (或 -std=gnu++0x)参数(没有 -std=c++11),我仍然收到此错误

错误:类型“MyClass”不是“MyClass”的直接基

我不想跳到结论,我浏览了网络,但似乎找不到任何有关它的信息。

顺便说一句,我正在使用 g++ (Debian 4.6.2-4) 4.6.2

I was just wondering if g++ actually complies with the C++11 standard of chained constructors (or whatever it's called).

example:

class MyClass
{
  MyClass(int x, int y = 0);
  MyClass(int y = 0) : MyClass(8, y) {}
};

I keep getting this error even though I've included the -std=c++0x (or -std=gnu++0x) parameter (there is no -std=c++11)

error: type ‘MyClass’ is not a direct base of ‘MyClass’

I don't want to jump to conclusions and I've looked around the net but can't seem to find any information about it.

By the way, I'm using g++ (Debian 4.6.2-4) 4.6.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深如许 2024-12-22 13:23:11

尚不支持(寻找委托构造函数)。

除此之外,你不觉得你的设计非常模糊吗? MyClass(1) 应该调用什么?

It's not yet supported (look for delegating constructors).

Other than that, don't you think your design is highly ambiguous? What should MyClass(1) call?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文