Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help getting this program to compile, \"TeachersAssistant\". I\'m using Vis

ID: 3536978 • Letter: N

Question

Need help getting this program to compile, "TeachersAssistant". I'm using Visual Studio 2010. Thanks for any help which could execute this program. :-)

Change the class TeachingAssistant to use nested classes. Add a member function as_employee to the class TeachingAssistant that will return an object of type Employee, and the member function as_student that will, from this value, return the Student object. Again show how to use the same value on a list of Students and a list of Employees.

#include <iostream>

#include "Employees.h"

#include "Students.h"

#include <string>

using namespace std;


class TeachingAssistants : public Students, public Employees

{

public:

string get_id();

string student_id();

string employee_id();


};


string TeachingAssistants :: get_id()

{

return Employees :: get_id();

}

string TeachingAssistants :: student_id()

{

return Students :: get_id();

}


int main()


{

//Declaring integers


TeachingAssistants* fred = new as_employee();

cout<<"Your teaching assistant is "<<fred->Employees::get_id()<<" ";

TeachingAssistants* cathy = new as_students();

cout<<"Your new teaching assistant is "<<cathy-<Students::get_id()" ";


system("PAUSE");

return 0;

}

========================================================================


#ifndef STUDENTS_H

#define STUDENTS_H


#include<iostream>

#include<fstream>

#include<string>


using namespace std;


class Students

{

public:

Students(string firstName,string lastName,string id)

{mFirstName=firstName;mLastName=lastName;mId=id;}


virtual void printStats()


{


cout<<"First name:"<<mFirstName<<endl;


cout<<"Last name:"<<mLastName<<endl;

cout<<"ID:"<<mId<<endl;

}

virtual void save(ofstream& outFile)


{


outFile<<"First name:"<<mFirstName<<endl;


outFile<<"Last name:"<<mLastName<<endl;


outFile<<"ID:"<<mId<<endl;


}


string getid()


{ return mId;}


protected:


string mFirstName;


string mLastName;


string mId;


};

class PM1: public Students


{


public:


PM1(string firstName,string lastName,string id,int age,string major, int grade):Students(firstName,lastName,id)


{mAge=age;mMajor=major;mGrade=grade;}


void Save(ofstream& outFile)


{


Students::save(outFile);


outFile<<"Age:"<<mAge<<endl;


outFile<<"Major:"<<mMajor<<endl;


outFile<<"Grade:"<<mGrade<<endl;


}


void printStats()


{


Students::printStats();


cout<<"Age:"<<mAge<<endl;


cout<<"Major:"<<mMajor<<endl;


cout<<"Grade:"<<mGrade<<endl;


}


protected:


int mAge;


string mMajor;


int mGrade;


};

class PM2: public Students


{


public:


PM2(string firstName,string lastName,string id,int age,string major,int grade2):Students(firstName,lastName,id)


{mAge=age;mMajor=major;mGrade2=grade2;}


void Save(ofstream& outFile)


{


Students::save(outFile);


outFile<<"Age:"<<mAge<<endl;


outFile<<"Major:"<<mMajor<<endl;


outFile<<"Grade:"<<mGrade2<<endl;


}


void printStats()


{


Students::printStats();


cout<<"Age:"<<mAge<<endl;


cout<<"Major:"<<mMajor<<endl;


cout<<"Grade:"<<mGrade2<<endl;


}


protected:


int mAge;


string mMajor;


int mGrade2;


};






#endif

==========================================================================

#ifndef EMPLOYEES_H

#define EMPLOYEES_H


#include<iostream>

#include<string>



using namespace std;


class Employees

{

private:

int idNum;

string empName;


public:

Employees();

~Employees();


Employees(int id = 0, char* n = "N/A") //Constructor

{

id = 0;

n = " ";

idNum = id;

empName = n;

}


void setIDNum(int i)

{

idNum = i;

}


void setName(char *n)

{

empName = n;

}


void setName(string n)

{

empName = n;

}


int getID()

{

return this->idNum;

}


bool operator==(int val)

{

return this->getID() == val;

}


string getName()

{

return empName;

}


bool operator==(const Employees& emply)

{

return this->idNum == emply.idNum;

}


bool operator > (const Employees& emply)

{

return this->idNum > emply.idNum;

}


bool operator < (const Employees& emply)

{

return this->idNum < emply.idNum;

}


};

#endif

Explanation / Answer

#ifndef STUDENTS_H
#define STUDENTS_H
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class Students
{
public:
Students(string firstName= "N/A",string lastName = "N/A",string id = "N/A")
    {mFirstName=firstName;mLastName=lastName;mId=id;}
   virtual void printStats()
{
      cout<<"First name:"<<mFirstName<<endl;
       cout<<"Last name:"<<mLastName<<endl;
        cout<<"ID:"<<mId<<endl;
    }
   virtual void save(ofstream& outFile)
    {
        outFile<<"First name:"<<mFirstName<<endl;
        outFile<<"Last name:"<<mLastName<<endl;
        outFile<<"ID:"<<mId<<endl;
    }
   string getid()
   { return mId;}
protected:
    string mFirstName;
    string mLastName;
    string mId;
};
class PM1: public Students
{
public:
    PM1(string firstName,string lastName,string id,int age,string major, int grade):Students(firstName,lastName,id)
    {mAge=age;mMajor=major;mGrade=grade;}
    void Save(ofstream& outFile)
    {
        Students::save(outFile);
        outFile<<"Age:"<<mAge<<endl;
        outFile<<"Major:"<<mMajor<<endl;
        outFile<<"Grade:"<<mGrade<<endl;
    }
    void printStats()
    {
        Students::printStats();
        cout<<"Age:"<<mAge<<endl;
        cout<<"Major:"<<mMajor<<endl;
        cout<<"Grade:"<<mGrade<<endl;
    }
protected:
    int mAge;
    string mMajor;
    int mGrade;
};
class PM2: public Students
{
public:
    PM2(string firstName,string lastName,string id,int age,string major,int grade2):Students(firstName,lastName,id)
    {mAge=age;mMajor=major;mGrade2=grade2;}
    void Save(ofstream& outFile)
    {
        Students::save(outFile);
        outFile<<"Age:"<<mAge<<endl;
       outFile<<"Major:"<<mMajor<<endl;
        outFile<<"Grade:"<<mGrade2<<endl;
    }
    void printStats()
    {
        Students::printStats();
        cout<<"Age:"<<mAge<<endl;
        cout<<"Major:"<<mMajor<<endl;
        cout<<"Grade:"<<mGrade2<<endl;
    }
protected:
    int mAge;
    string mMajor;
    int mGrade2;
};
#endif


#ifndef EMPLOYEES_H
#define EMPLOYEES_H
#include<iostream>
#include<string>
using namespace std;
class Employees
{
private:
int idNum;
string empName;
public:
Employees(int id = 0, string emp_Name = "N/A") //Constructor
{
idNum = id;
empName = emp_Name;
}
void setIDNum(int i)
{
idNum = i;
}
void setName(char *n)
{
empName = n;
}
void setName(string n)
{
empName = n;
}
int getID()
{
return this->idNum;
}
bool operator==(int val)
{
return this->getID() == val;
}
string getName()
{
return empName;
}
bool operator==(const Employees& emply)
{
return this->idNum == emply.idNum;
}
bool operator > (const Employees& emply)
{
return this->idNum > emply.idNum;
}
bool operator < (const Employees& emply)
{
return this->idNum < emply.idNum;
}
};
#endif

#include <iostream>
#include "Employees.h"
#include "Students.h"
#include <string>
using namespace std;

class TeachingAssistants : public Students, public Employees
{
public:
int get_id();
string student_id();
string employee_id();
    TeachingAssistants()
{
    //Employees();Students();
}
};

int TeachingAssistants :: get_id()
{
return Employees :: getID();
}
string TeachingAssistants :: student_id()
{
return Students :: getid();
}
int main()
{
//Declaring integers
TeachingAssistants* fred = new TeachingAssistants();
cout<<"Your teaching assistant is "<<fred->Employees::getID()<<" ";
TeachingAssistants* cathy = new TeachingAssistants();
cout<<"Your new teaching assistant is "<<cathy->Students::getid()<< " ";
system("PAUSE");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote