CodeToad Forums » C++ » how to set up the project in vc ++ for the class with container member data?
|
|
|
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);
}
|
|
|
|
|
|
|
// |