#ifndef _EMPLOYEE_H
#define _EMPLOYEE_H
#define _ProductionWorker_h
#pragma warning(disable: 4996)
#include <cstring>
#include <iostream>
#include <cstdlib>
using namespace std;
//const int SIZE = 40;  // Array Size

class Employee //Definition of Employee Class
{
	private:
		//char employName[SIZE];
		char *employName;
		int employNum;
		int hireDate;
	public:
		Employee();
		//Constructor
	Employee(char *e)
		{employName = new char[strlen(e)+1];
		strcpy(employName, e);}
		

			//Copy Constructor
	Employee(const Employee &obj)
		{employName = new char[strlen(obj.employName)+1];
		strcpy(employName, obj.employName);}

	//Destructor
	~Employee()
	{delete [] employName;}

		const char *getempName()
		{return employName;}
		void empnum(int);
		void emphdat(int);
		int getempnum()const;
		int getempdat()const;

};


void Employee::empnum(int n)
{
	employNum = n;

}

void Employee::emphdat(int d)
{
	hireDate = d;

}
int Employee::getempnum()const
{
	return employNum;
}
int Employee::getempdat() const
{
	return hireDate;
}
class ProductionWorker:public Employee
{
	private:
		int Shift;
		double HPayRate;

	public:
		void sh(int);
		void prate(double);
		int getShift()const;
		double getHPayRate()const;
};		

void ProductionWorker::sh(int s)
{
	Shift = s;

}

void ProductionWorker::prate(double p)
{
	HPayRate = p;

}

int ProductionWorker::getShift() const
{
	
	
	return Shift;
	
}
double ProductionWorker::getHPayRate() const
{
	return HPayRate;
}

#endif
#include <iostream>
#include "Employee.h"
#include "ProductionWorker.h"
using namespace std;

int main()
{
	Employee Info;
	char e;  //Definition for employee name
	int id;	 //Definition for Employee ID
	int hd;	 //Definition for Employee Hiredate
	//Request For user input
	cout << "What is the Employee's Name \n "; 
	cin.getline();
	
		
	cout << "Enter the Employee Number \n ";
	cin >> id;
	
	cout << "Enter the Employee Hire Date \n ";
	cin >> hd;
	
	//Storage for user input
	Info.getempName();
	Info.empnum(id);
	Info.emphdat(hd);

	//Output for user input

	cout << "\nHere is the Employee Name "<< Info.getempName()<<endl;
   
	cout << "\nHere is the Employee Number "<< Info.getempnum()<<endl;
	
    cout << "\nHere is the Employee Hire Date "<< Info.getempdat()<<endl;;
	
	

	int pShift;		//Definition for shift
	double p_rate;	//Definition for employee payrate

	//Requesting input from user

	cout << "\nEnter employee shift (shift 1 = day and shift 2 = night). ";
	cin >> pShift;
	
	//Input validation for shift

	 if (pShift < 1 || pShift> 2)
	{
		cout << "valid inputs are 1 or 2." <<endl;
		cin >> pShift;
	}
	ProductionWorker ShiftPay;
	
	ShiftPay.sh(pShift);
	
	//Output for user input

	cout << "The shift of the Employee is " <<ShiftPay.getShift()<<endl;
	

	cout << "\nEnter employee payrate. ";
	cin >>  p_rate;

	ShiftPay.prate(p_rate);
	cout << "The payrate of the Employee is " <<ShiftPay.getHPayRate()<<endl;


	

	
	
	
	
	
		
	
	
	
		
	
 system("pause");
return 0;

}

Need help in completing cin.getline(); for the above code. Do not know what to input to get return of employeName on output.

Recommended Answers

All 2 Replies

Try looking up the syntax in your text. There's no way you wrote all that code without some form of book or on-line help.

Thank you for the help, I used my text books as a reference to help me write this code for my homework assignment. The text book does not give you examples for everything. This assignment has been submitted to my professor already. I am requesting the help for my own knowledge. If this is an inappropriate post I will remove it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.