Actually it isn’t. I just found this line in a Youtube video and did not understand what it means. In other languages like Object Pascal for instance, it would mean a public class member pointer (or static member), but I guess it is something different in C++.
If you could tell me the name of this C++ language resource I could look for it in Google. So far I have found only things like common class declarations or instance pointers, which I already know.
Sorry to ask again but I searched for forward declarations in C++ and I only got results like so:
class A;
class B { A* someMember; }
class A { … }
It makes sense and is similar to other languages I know. But in the example I mentioned in my first post, the class keyword is used inside the B declaration. In the example above, it would be:
class B {
class A* someMember;
}
Edit (typo): Is it still a forward declaration? I think it’s strange because the class was UStaticMeshComponent, which was referenced in the includes.
int main()
{
Bar Bar(1);
class Bar Bar2(2); // elaborated type
}
Since the first variable is called Bar, the second time you write Bar to declare a Bar you need the keyword class to disambiguate and specify this is a type, otherwise you get an error because the expression “variable_name undeclared_var_name(2)” have no meaning.
Yes, putting class or struct before a member declaration is just an inline forward declaration. Your two examples are equivalent.
As to why UStaticMeshComponent was forward declared and included in the code you found, maybe the variable was originally forward declared when it was the only reference to the class in the file, but then the header needed to be included for some other usage later.