static variables: UNRESOLVED EXTERNAL

Started by
1 comment, last by Marty666 19 years, 6 months ago
Hi all, I have a class defined in my header with:

	static vector<tVec3> Vertices;
	static numverts;



I use them in the .cpp file of this class and get these errors: cFace2.obj : error LNK2001: unresolved external symbol "private: static int cFace::numverts" (?numverts@cFace@@0HA) cFace2.obj : error LNK2001: unresolved external symbol "private: static class std::vector<struct tVec3,class std::allocator<struct tVec3> > cFace::Vertices" (?Vertices@cFace@@0V?$vector@UtVec3@@V?$allocator@UtVec3@@@std@@@std@@A) What am i doing wrong? I tried to make it public, private and protected (since my class is a friend class of itself)... It doesn't work anyways. Thanx, Marty PS: - I'm using MSVC6. - static variables only work in the file they're declared in, but I get loads of errors when I put this at the beginning of the cpp file.

extern static cFace::vector<tVec3> Vertices;
extern static cFace::int numverts;


[Edited by - Marty666 on October 3, 2004 8:12:38 AM]
_____ /____ /|| | || MtY | ||_____|/Marty
Advertisement
In your cpp file instead of the extern stuff...

vector<tVec3> cFace::Vertices;int cFace::numverts;


Make sure you include the header too.
thanx a lot!
_____ /____ /|| | || MtY | ||_____|/Marty

This topic is closed to new replies.

Advertisement