Hallo,

I am working on a program where I need to create a lot of different classes of almost the same type. But I am not sure how I should design the program so that it is easy to add a new class.

Here are the restrictions which makes it harder.
The classes has to work with the rest of the program (which is not written by me, and can not be change by me).

This is the base class which I can derive from in order to create a new class
Code:
class Man 
{
public:
	virtual void gatherInfo( /* a variable map */ ) = 0;
	virtual void doWork() = 0;
}
Right now I am doing this when I create new classes:
Code:
class IronWorker : public Man
{
	public:
		void gatherInfo( /* a variable map */ );
		void doWork();

	public:
		std::string m_name;
		int m_age;
		std::string m_workplace;

		std::string m_factoryName;
		std::string m_ironType;
}

class GarderWorker : public Man
{
	public:
		void gatherInfo( /* a variable map */ );
		void doWork();

	public:
		std::string m_name;
		int m_age;
		std::string m_workplace;

		std::string m_houseAdress;
		std::string m_floworNames[50];
		int m_kgDirtUsed;
}
When the program starts it goes into the gatherInfo() function of everyman and take the information in that map and stores it in the member variables. There are several variables that will be the same for every derived class (like name and age) but as of now I have to duplicate that code in every worker.

What I would like is to create classes more like this:
Code:
// A "new" base class
class Worker : public Man
{
public:
	void gatherInfo( /* a variable map */ );
	void doWork();

public:
	std::string m_name;
	int m_age;
	std::string m_workplace;
};

class IronWorker : public baseWorker
{
	public:
		void gatherInfo( /* a variable map */ );
		void doWork();

	public:
		std::string m_factoryName;
		std::string m_ironType;
}

class GarderWorker : public baseWorker
{
	public:
		void gatherInfo( /* a variable map */ );
		void doWork();

	public:
		std::string m_houseAdress;
		std::string m_floworNames[50];
		int m_kgDirtUsed;
}
In the code there the base variables will be gathered by the baseWorker class. But the gatherInfo function in baseWorker would never be called as it is a pure virtual function.

Any ideas on how to create a more user friendly way of doing this?
(The two virtual functions are the only two function that is called by the program)