我學習虛幻引擎編碼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++,翻閱虛幻引擎的源代碼將是我最不可能的建議。 –