【发布时间】:2012-12-31 08:40:12
【问题描述】:
在使用 Visual Studio Nov 2012 CTP C++ Compiler 编译此语法时遇到问题……只是想确保我没有遗漏一些明显的东西。
谢谢!
编辑:删除了 Header 以使其更加简单。
class Location
{
public:
Location();
};
class Shape
{
public:
Shape();
Shape(Location location);
};
// Doing this by pointer works ...
// Shape::Shape(Location* location){}
// Shape::Shape() : Shape(new Location()){}
Shape::Shape(Location location)
{
}
Shape::Shape()
: Shape(Location())
// error C2143: syntax error: missing ';' before ':'
{
// int x = 0;
// (void) x; // Added these two lines in some cases to get it to compile.
// These two lines do nothing, but get around a compiler issue.
}
【问题讨论】:
-
如果这是编译器的内部错误,则意味着编译器出现问题,而不是您的代码。在我看来这是正确的。您可能想在 MSDN 上提交错误报告。
-
应该永远发生内部错误。如果是这样,它总是编译器的一个错误,而不是你的错。
-
作为旁注/讨厌,使用
void表示函数不带参数... AUGH! -
你也忘记了所有的分号。也许你的编译器只是生你的气,想让你别管它。
-
我猜这不是真正的代码,缺少分号,没有前向声明等。
标签: c++ c++11 constructor visual-studio-2012 delegation