Firstly, apologies for the lack of commenting, it will be commented when the program works properly (lol), I'm creating a program which creates a test harness for 3 subjects, employees. This will display their name, ID and payrate per hour, it will then calculates the total amount in 37.5hours.

Again, apologies for 0 comments and crude code.
Any help would be greatly appreciated

#include <iostream>
using namespace std;

class emp
{
private:
		char empname[25];
		char empid[10];
		char rate[20];
		char total[10];
public:
	void getDetails()
	{
		cout<<"Employee Name: \n" << empname;
		cout<<"Employee ID: \n" << empid;
		cout<<"Hourly Rate: \n" << rate;
	}
	void setDetails()
	{
		cout<<"Employee Name: Smith \n";
		cin.getline(empname,25);
		cout<<"Employee ID: BR0900 \n";
		cin.getline(empid,10);
		cout<<"Hourly Rate: £6.30 \n";
		cin.getline(rate,20);
        cout<<"Employee Name: Talbot \n";
		cin.getline(empname,25);
		cout<<"Employee ID: MA0640 \n";
		cin.getline(empid,10);
		cout<<"Hourly Rate: £5.40 \n";
		cin.getline(rate,20);
		cout<<"Employee Name: Adams \n";
		cin.getline(empname,25);
		cout<<"Employee ID: SA0120 \n";
		cin.getline(empid,10);
		cout<<"Hourly Rate: £12.00 \n";
		cin.getline(rate,20);
		cout<<"Total Pay: £888.75 \n" << rate;
		cin.getline(rate,10);
	}
};

int main()
{

    empname empname1;
	empid empid1;
	rate rate1;

	empname1.setDetails();
	empid1.setempidDetails();
	rate1.setrateDetails();

	empname1.getDetails();
	empid1.getempidDetails();
	rate1.getrateDetails();

	return 0;
}

Sorry, the issues I received when compiling was;

In function `int main()':
46: error: `empname' was not declared in this scope
46: error: expected `;' before "empname1"
47: error: `empid' was not declared in this scope
47: error: expected `;' before "empid1"
48: error: `rate' was not declared in this scope
48: error: expected `;' before "rate1"
50: error: `empname1' was not declared in this scope
51: error: `empid1' was not declared in this scope
52: error: `rate1' was not declared in this scope
46: warning: unused variable 'empname'
47: warning: unused variable 'empid'
48: warning: unused variable 'rate'

1. The type empname does not exist. It is 'emp'. The variables empname, empid, etc are part of the class emp. You need an instance of 'emp', where you can get/set empname, empid, etc.

This article has been dead for over six months. Start a new discussion instead.