Class/Struct Within a class

this is my class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Editor {
public:
	static const int FeaturesAmount = 6;
	static const int MaxFeatures = 50;
	enum Feature
	{
		SpikesLeft,
		SpikesUp,
		SpikesRight,
		SpikesDown,
		End,
		Start
	};
	static void Load();
	static void Display();
	static bool Unload();

	static struct _Features{
		Editor::Feature Feature;
		int X, Y;
	} Features[Editor::MaxFeatures];
	
};


It compiles, but when i do this in my code:

1
2
		Editor::Features[1].X = 100;
		Editor::Features[1].Feature = Editor::End;


I get the following error:

unresolved external symbol "public: static struct Editor::_Features * Editor::Features" (?Features@Editor@@2PAU_Features@1@A)


Last edited on
static member vars need to be instantiated.

Put this line globally in one and only one cpp file:

 
Editor::_Features Editor::Features[Editor::MaxFeatures];
You need to define static class variables (that are not static const) somewhere in you code.
So somewhere in your cpp file:
1
2
//define the static Freaturs array
Editor::_Features Editor::Features[Editor::MaxFeatures];
Ah, thanks alot, i completely forgot about that! :).
Topic archived. No new replies allowed.