Unresolved external 'class::member' referenced from class.OBJ

Hi,
I have a class linestorage which has a static member S (represents lines of words of characters).
The problem is I don't know how to access this member in a member function. I am getting this error message

Info :Linking C:\DOCUMENTS AND SETTINGS\DELL.DFHWHLB1\MY DOCUMENTS\SPRING 09\CSCI 250\HW\HW1\HW1_P2\kwic.exe
Error: Error: Unresolved external 'LineStorage::S' referenced from C:\DOCUMENTS AND SETTINGS\DELL.DFHWHLB1\MY DOCUMENTS\SPRING 09\CSCI 250\HW\HW1\HW1_P2\LINESTORAGE.OBJ

could you please help me to solve it.

//---------------- linestorage.h ----------------
#ifndef linestorage_H_
#define linestorage_H_
#include <vector.h>
using namespace std;

class LineStorage
{

private:
static vector <vector <vector<char> > > S;
public:
void setchar(int,int,int,char);
};
#endif
//---------------- linestorage.cpp ----------------

#include <iostream.h>
#include <conio.h>
#include "LineStorage.h"

void LineStorage::setchar(int l,int w,int c,char d)
{
vector <char>::iterator it=LineStorage::S[l][w].begin();
LineStorage::S[l][w].insert((it+c-1),d);
}
Hello !

You must initialize you static member in the implementation file.
In your case, you must use:
vector< vector<char> > Linestorage::S=<what_you_want>

Hope this helps !
How can I initialize S if it starts as an empty vector??
Just declare it outside the class
vector <vector <vector<char> > > LineStorage::S;
Last edited on
Topic archived. No new replies allowed.