我学习虚幻引擎编码C++,我得到这个语法我真的不明白:类指针*的含义是什么?
class USphereComponent* ProxSphere;
我认为这意味着创建一个类,但这个类是一个指针?
但结果只是从现有的类USphereComponent中创建一个名为ProxSphere的对象。
任何人都可以解释这个语法的实际意义,它的用法?
我学习虚幻引擎编码C++,我得到这个语法我真的不明白:类指针*的含义是什么?
class USphereComponent* ProxSphere;
我认为这意味着创建一个类,但这个类是一个指针?
但结果只是从现有的类USphereComponent中创建一个名为ProxSphere的对象。
任何人都可以解释这个语法的实际意义,它的用法?
class Someotherclass; that has not been defined yet
class HelloWorld
{
Someotherclass* my_pointer;
};
or alternative:
class HelloWorld
{
class Someotherclass* my_pointer;
};
第一个显然是正确的,如果你有多个指针(或引用)这样的类尚未定义。
第二个比较好? (我不知道),如果你只需要做一次,否则做
class HelloWorld
{
class Someotherclass* my_pointer;
class Someotherclass* my_pointer2;
class Someotherclass* my_pointer3;
void func(class Someotherclass* my_pointer, class Someotherclass& my_ref);
};
可能不是最好的。
谢谢!所以我可以假设其他类* myPointer与Someotherclass * myPointer类几乎相同? –
这完全一样,都是指向Someotherclass类的指针。 – Jts
感谢您为我清除! –
请拿起一本教科书并系统地学习C++。 –
这是一个类指针声明,不多不少。 –
如果有人想学习C++,翻阅虚幻引擎的源代码将是我最不可能的建议。 –