Download

Member redeclared outside of function in a cpp file

Just found this in the engine and not entirely sure what it does:
.h


private:
	...

	/** A list of all available SoundNode classes */
	static TArray<UClass*> SoundNodeClasses;

.cpp


TArray<UClass*> USoundCueGraphSchema::SoundNodeClasses;

This line in the cpp is outside of a function. Is that so the static member can be used inside a none-static function or something?

Every static variable must be initialized before it is used for the first time. What you see is initialization of SoundNodeClasses. Because it is TArray, which is class, this line cause its default constructor to be called.

Ah yes, the fact nothing got assigned fooled me. Makes sense it would call the default constructor like this. Thanks!