Hi,
I am stuck trying to figure out how to include a class within a class and how to properly call members of a class from the main(). I cannot figure out what these error messages mean. I would greatly appreciate and insight into my dilemma. Thank You, C.D.
Enclosed is the last attempt I made with the project.
// PEmployee header
#include <string>
#include "Lab10.h"
using namespace std ;
class PEmployee
{
public:
PEmployee() ;
PEmployee(string employee_name, double initial_salary) ;
void set_salary () const ;
double set_salary(double new_salary) const ;
string get_name() const ;
void read_salary() ;
private:
person person_data ;
double salary ;
string name ;
} ;
// person header
#ifndef Lab10
#define Lab10
#include <string>
using namespace std ;
class person
{
public:
person() ;
person( string pname, int page ) ;
string get_name() const ;
int get_age() const ;
void read_name() ;
void read_age() ;
private:
string name ;
int age ;
} ;
#endif
// person definitions
#include <string>
#include "Lab10.h"
using namespace std ;
class PEmployee
{
public:
PEmployee() ;
PEmployee(string employee_name, double initial_salary) ;
void set_salary () const ;
double set_salary(double new_salary) const ;
string get_name() const ;
void read_salary() ;
private:
person person_data ;
double salary ;
string name ;
} ;
// PEmployee definitions
#include <iostream>
#include <string>
#include "Lab10.h"
#include "PEmployee.h"
using namespace std ;
PEmployee :: PEmployee()
{
salary = 0 ;
}
PEmployee ::PEmployee(string employee_name, double initial_salary)
{
salary = initial_salary ;
name = employee_name ;
}
double PEmployee :: set_salary(double new_salary) const
{
double salary = new_salary ;
return salary ;
}
string PEmployee :: get_name() const
{
return name ;
}
void person :: read_name()
{
person next ;
next.read_name ;
string employee_name = next.name ;
}
void PEmployee :: read_salary()
{
double new_salary = 0 ;
cout << "Please enter the salary for the person " ;
cin >> new_salary ;
}
// attempt to call member function
void main()
{
person next ;
cout << next.read_name ;
system("PAUSE") ;
}