hello guys... I have a file MyClass.cpp inwhich I declared a vector array. I then added some string data to it and want to access it in MyProjDlg.cpp. It is dialoged based app in vc6. Here it is

MyClass.cpp
-----------
   using namespace std;
   typedef vector<LPTSTR> StudentData;

   //some code here...
   void someFunc()
   {
       //vector array
       StudentData std;
       //some loop
       std.push_back(stdentName);
   }

MyProjDlg.cpp
-------------

//Now here in [I]MyProjDlg.cpp[/I]...what should I do to access this vector array and 
//put that data in Listbox..here it is what I tried so far but no result

extern StudentData std;

    //some loop to enter this data in listbox....
    for (int i=0; i<5; i++)
       listbox.AddString(std.pop_back());

it is showing 7 defferent errors....any idea whats wrong im doing?

Recommended Answers

All 4 Replies

Don't use std in c++ programs as std is the name of a namespace.
You have to repeat the typedef statement in MyProjDlg.cpp

typedef vector<LPTSTR> StudentData;
extern StudentData  stdData;

I have done exactly the same....but again these errors

error C2143: syntax error : missing ';' before '<'
error C2143: syntax error : missing ';' before '<'
error C2146: syntax error : missing ';' before identifier 'std'
error C2065: 'std': undeclared identifier
error C2146: syntax error : missing ';' before identifier 'std'
error C2065: 'std': undeclared identifier
error C2228: left of '.push_back' must have class/struct/union type
error C2143: syntax error : missing ';' before '<'
error C2143: syntax error : missing ';' before '<'
error C2146: syntax error : missing ';' before identifier 'std'
fatal error C1004: unexpected end of file found

Since I can't see your monitor my GUESS is that the *.cpp file is missing one or more header files.

thanx for ur time...alot of web serfing gave me the result....FINALLY.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.