Reputation:
In Unreal Project I have this line:
class USpringArmComponent* CameraBoom
and
class UCameraComponent* FollowCamera
And I haven't ever seen this syntax in c++. What does it mean?
Upvotes: 3
Views: 283
Reputation: 955
That's just telling the compiler that UCameraComponent
is a class. Not anything else. It's like in C you put struct
before any structure variable declarations.
This syntax is useful when you have some messy code (or to convey that it is a class verbosely to the developer).
For example:
class counter
{
// bla bla bla...
};
void foo()
{
int counter = 0; // Oops someone declared a variable called counter.
// How am I going to declare a variable of type `counter`?4
// counter actual_counter; // Syntax error: expected ';' after expression.
//Because counter is a variable
class counter actual_counter; // You prepend `class` to the deceleration
}
Upvotes: 3
Reputation: 234705
It's an elaborated type specifier:
https://en.cppreference.com/w/cpp/language/elaborated_type_specifier
Upvotes: 6