Archived

This topic is now archived and is closed to further replies.

Problem with STL vectors?

This topic is 5748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
You have only declared the static variable, you also need to define it. You should add this to your implementation file:

vector<cWindow> cWinList::winList;

Share this post


Link to post
Share on other sites