I am currently taking a c++ and was jusy recently given an assignment using class inheritance. was wondering if anyone could help explain what im doin wrong.
Define a base class person that will contain universal information, including name, address, birth date, gender and identification (student, worker etc). Derive from this class the following classes:
Student
Worker
Student_worker
Write a program that asks user to input information (student, worker etc) and creates a list of persons. Give user choice to view list by gender and by identification( list of people who are students, list of people who are workers etc).
im getting alot of undeclared identifier errors. sorry all i would ask my prof but she doesn't speak english too good. lol
im getting alot of undeclared identifier errors. sorry all i would ask my prof but she doesn't speak english too good. lol
Evidently, you don't speak english too "well" either. But that's beside the point. I noticed that you are dynamically allocating a Worker and Student_Worker class. I don't see a #include "Worker.h" or #include "Student_Worker.h". Your main function has dependencies on those classes and therefore your main.cpp will also have to include the header files where those classes are declared.
class Student_Worker :
public Student, public Worker
{
public:
Student_Worker(void);
Student_Worker(string 1, string 2);
//Student_Worker::Student_Worker():Worker()
//{}; this doesn't belong here, and the default constructors will be used by default, so you
// don't even need to define a default constructor.
~Student_Worker(void);
};
and if you want the print of the corresponding class to be used, you must declare it virtual.