Came across a snippet that I'm not sure how to interpret, in a header file:
...
private:
class Ellipsoid * ellipse;
It's later initialized in the cpp:
ellipse = (Ellipsoid *) something->GetEllipse();
The class keyword on this data member is throwing me off. Is this a pointer to a class/type that inherits from Ellipsoid? Thus, is "ellipse" to be treated like a reference to a type?
The class
keyword used there simply declares the symbol Ellipsoid
to be a class
at the site of its usage.
If the compiler already knows that symbol to be a class, it's optional.
class Ellipsoid;
class MyClass
{
private:
/*class*/ Ellipsoid * ellipse;
};
However, the usage you show will prevent compiler errors if the symbol is as-yet undeclared.
//class Ellipsoid;
class MyClass
{
private:
class Ellipsoid * ellipse;
};
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments