在使用Visual Studio Nov 2012 CTP C++編譯器編譯此語法時出現問題......只是想確保我沒有錯過顯而易見的東西。C++ 11使用新實例參數委託構造函數?
謝謝!
編輯:刪除標題,使其更簡單。
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上提交錯誤報告。 –
內部錯誤應該永遠不會發生。如果是這樣,它總是編譯器的一個bug,並且從來不是你的錯。 –
作爲一個旁註/寵物peeve,使用'void'來表示函數不需要任何參數...... ** AUGH **! –