在虚幻引擎射击游戏示例中的“DataType * Variable”类中是什么'类' [英] what is 'class' in 'class DataType* Variable' in Unreal Engine Shooter Game Sample
问题描述
我最近下载了Unreal 4 Engine的Shooter Game,我只是想分开c ++,但我的c ++不是最好的我注意到一个变量
I recently downloaded the Shooter Game for Unreal 4 Engine and I am just trying to pick apart the c++ but my c++ isn't the best I notice a variable called
class AShooterCharacter* MyPawn;
在 ShooterWeapon.h
我试图理解 class
部分是什么。
I am trying to understand what the class
part is.
我注意到有人拒绝了我的问题,所以我将其更改为一个问题。我希望人们愿意帮助,而不是降低我的问题。特别是在编程中
I notice people downed my question so I changed it to one question. I hope people are willing to help rather then degrade my question. Theres no such thing as a dumb question :)... Especially in programming
推荐答案
如果 AShooterCharacter
已经在范围内,那么它可能意味着基本上没有任何东西。
If AShooterCharacter
is already in scope, then it probably means basically nothing.
class AShooterCharacter* MyPawn;
// ^ the same as just:
// AShooterCharacter* MyPawn;
在C中,命名结构类型时,必须使用 struct
关键字:
In C, when naming structure types, you had to use the struct
keyword:
struct Foo
{
int x, y, z;
};
struct Foo obj;
在C ++中,你不需要这样做,因为 Foo
本身就是一个可命名的类型:
In C++, you don't need to do that because Foo
becomes a nameable type in its own right:
Foo obj;
但你仍然可以写 struct Foo
如果你想。
But you still can write struct Foo
if you want to.
同样适用于 class
如何定义语言语法和语义。
The same applies for class
, just as a consequence of how the language grammar and semantics are defined.
只有两次会产生影响。
您可以使用它来指定要引用范围内类型名称,否则会被其他一些名称,例如:
You can use it to specify that you want to refer to an in-scope type name when it is otherwise being hidden by some other name, e.g.:
class Foo {};
int main()
{
const int Foo = 3;
// Foo x; // invalid because `Foo` is now a variable, not a type
class Foo x; // a declaration of a `Foo` called `x`;
}
但是如果你发现自己需要有更大的问题!
But if you find yourself "needing" this then, in my opinion, you have bigger problems!
否则, / p>
Otherwise, it is the same as doing this:
class Foo; // a forward declaration
Foo* x;
可以说,如果要转发声明类型并立即声明一个指针
Arguably it saves a line of code if you are going to forward declare the type and immediately declare a pointer to an object of that type.
这是不常见的风格。
这篇关于在虚幻引擎射击游戏示例中的“DataType * Variable”类中是什么'类'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!