initializing a static vector
From: Wattim (wattim_at_aol.com)
Date: 03/31/04
- Next message: Simon Biber: "Re: Challenging macro with default value"
- Previous message: Thomas Matthews: "Re: What is problematic about static functions?"
- Next in thread: Mike Wahler: "Re: initializing a static vector"
- Reply: Mike Wahler: "Re: initializing a static vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Mar 2004 15:52:52 GMT
I am a newbe at c++ and the stl, so forgive me if I don't use the proper
vocabulary, so here it goes:
I have a class that I want to contain a static vector of strings like so:
// foo.h file ---------------------------
#include <string>
#include <vector>
class foo
{
public:
// ctors and dtor are here
// member variables and functions declared here
// my static vector
static std::vector<std::string> vstring;
}
Like any other static member, I need to initialize vstring in my
implementation file, foo.cpp, but I am getting a linker error if I do the
following:
// foo.cpp file -------------------
#include "foo.h"
#include <string>
#include <vector>
using namespace std;
…
// initialize vstring - how should I do this?
vector<string> foo::vstring=NULL;
So, how do I initialize a vector when it is used as a static member of a class?
- Next message: Simon Biber: "Re: Challenging macro with default value"
- Previous message: Thomas Matthews: "Re: What is problematic about static functions?"
- Next in thread: Mike Wahler: "Re: initializing a static vector"
- Reply: Mike Wahler: "Re: initializing a static vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]