Problem with STL vectors?

Started by
2 comments, last by Sheep 22 years, 1 month ago
Hello everyone. I was just messing with having multiple windows in one instance of the program, so I decided to make a class that keeps a list of the windows:
  
class cWinList
{
private:
	static vector<cWindow> winList; //cWindow is my

                                        // Window class


public:
	static void Add( cWindow window );
};   
Then when I define the add funtion to be this:
  
void cWinList::Add( cWindow window )
{
	winList.push_back( window );
}   
I get a linker error saying error LNK2001: unresolved external symbol "public: static class std::vector > cWinList::winList" (?winList@cWinList@@2V?$vector@VcWindow@@V?$allocator@VcWindow@@@std@@@std@@A) Does anyone know what I am doing wrong? Thanks.
Advertisement
You have to ALSO declare static members outside the class definition, like this:

vector[cWindow] CWinList::winList;

I believe that's correct.

BAH - substitute less than and greater than for the brackets!!


[edited by - Waverider on March 21, 2002 10:27:06 AM]

[edited by - Waverider on March 21, 2002 10:27:28 AM]
It's not what you're taught, it's what you learn.
You have only declared the static variable, you also need to define it. You should add this to your implementation file:

vector&ltcWindow> cWinList::winList;
Thanks alot guys!

This topic is closed to new replies.

Advertisement