codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  how to set up the project in vc ++ for the class with container member data?  qbsu21th at 23:36 on Monday, March 21, 2005
 

Dear Sir/Madam:

in the following program, the set<String> prj is the member data in the Programmer class, however, when compile the main.cpp file, get the error of "error C2501: 'set' : missing decl-specifiers". the set class is in the devstudio/vc/include directory. i setup the project as win32 console application. it will be very appreciated if someone can help me to figure out why the error occurs?

thanks!
David


#include "string.h" // String
#include <set> // set

class Programmer;
class Analyst;

class Staff_member {
String nm;

public:
Staff_member(const String& name) : nm(name) {}
Staff_member(const Staff_member& x) : nm(x.nm) {}
~Staff_member() {}
Staff_member& operator=(const Staff_member& x);

const String& get_name() const { return nm; }
void set_name(const String& name) { nm = name; }

void print(ostream& o) const { o << "NAME: " << nm << '\n'; }
};

class Programmer : public Staff_member {
set<String> prj;
Analyst* mgr;

public:
Programmer(const String& name, Analyst* analyst);
Programmer(const Programmer& x);
~Programmer();
Programmer& operator=(const Programmer& x);

const set<String>& get_projects() const { return prj; }
bool assign_to_project(const String& project);
bool remove_from_project(const String& project);

Analyst* get_manager() const { return mgr; }
void set_manager(Analyst* analyst);

String get_title() const { return "Programmer"; }
void print(ostream&) const;
};

int main()
{
Staff_member staff;

load_staff(&staff);
print_staff(staff);

// fire Mark and remove him from James' team
Staff_member::iterator mark = find_staff_member(staff, "Mark Richards");
if (mark != staff.end()) {
delete *mark;
staff.erase(mark);
}
print_staff(staff);
}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007