Having an issue getting this syntax to compile using the Visual Studio Nov 2012 CTP C++ Compiler ... Just wanted to be sure I wasn't missing something obvious.
Thanks!
EDIT: Removed Header to make it even simpler.
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.
}
// .h Simplification
class Location
{
public:
Location() {}
Location(Location const& other) {}
};
class Shape
{
Shape();
Shape(Location location);
};
// How about by value or reference?
Shape::Shape(Location location)
{
}
Shape::Shape(void)
: Shape(Location()) // error C1001: An internal error has occurred in the compiler.
{
}
int main() {}
The above code compiles and runs in gcc 4.7.2
I had to make a few changes to your code to make it compile. When simplifying things, try to keep the simplified code compiling. http://sscce.org/