Program not running I'm not sure of he problem

//Employee.h
#ifndef CLASS_H
#define CLASS_H

class Employee 
{
protected :
	char *firstName;
	char *lastName;

public:
	Employee ();
	Employee ( char, char );
	
	//accessors
	//retrieve
	const char *setfirstName (char);
	const char	*setlastName (char);

	//mutators
	//return
	const char *getfirstName (char);
	const char *getlastName (char);
	
	
	void print ();

};
#endif 

//Secretary.h
#ifndef SECRETARY_H
#define SECRETARY_H



class Secretary: public Employee
{
protected:
	int salary;



public :
	Secretary ();
	Secretary ( int, char, char);
	
	//accessor
	int setsalary ();
	
	//mutator
	int getsalary ()const ;

	void print ()const;
};
#endif 

//Employee.cpp
#include <iostream>
#include "Employee.h"
using namespace std;


Employee::Employe()
{
}

Employee::Employee (char first, char last)
{
	firstName = first;
	lastName = last;
}

 Employee:: setfirstName (char *fisrt)
{
	strcpy_s ( firstName, first);
}

 Employee::setlastName ( char * last)
{
	strcpy_s (lastName, last);
}

void Employee:: getfirstName ( char)
{
	return first;
}

void Employee::getlastName (char )
{
	return last;
}


void print()
{
	cout << "first name: " << firstName <<
		cout <<"last name: " << lastName <<;
};


//Secretary.cpp
#include "Secretary.h"
#include <iostream>
using namespace std;

Secretary::Secretary ( int salary, const char firstName, const char lastName)
: Employee ( first, last)
{
salary =sal;
}

int Secretary :: setsalary ( )
{
	sal = 0;

}

void Secretary::getsalary (int) const
{
	return salary;
}

void Secretary::print() const
{
	cout << "first name: " << firstName <<
		cout <<"last name: " << lastName <<; 
};

//Main.cpp
#include <iostream>
#include "Employee.h"
#include "Secretary.h"
#include <conio.h>
using namespace std;
//Create a secretary sec1 whose first name is “Empress”, last name is  “MENEN” and whose salary is b.	//Create a secretary pointer sec2 whose first name is “Princess”, last name is  “Victoria” and whose salary is 33.33 (Dynamic memory allocation)
//c.	Call the print() of secretary from sec1
//d.	Call the print() of secretary from sec2
//e.	Call the print() of Employee from  sec2





int main (void)
{

	Secretary sec1;

	sec1.Secretary ( "Empress”, MENEN, 77.70");

	Secretary sec2;

	Secretary *ptr;

	ptr -> (" Princess, Victoria, 33.33");

	sec1.print;

	sec2.print;

};

These are the error messages I am getting

1>g:\oop c++\employee\employee\employee.cpp(6) : error C2039: 'Employe' : is not a member of 'Employee'
1> g:\oop c++\employee\employee\employee.h(5) : see declaration of 'Employee'
1>g:\oop c++\employee\employee\employee.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>g:\oop c++\employee\employee\employee.cpp(8) : warning C4508: 'Employe' : function should return a value; 'void' return type assumed
1>g:\oop c++\employee\employee\employee.cpp(12) : error C2440: '=' : cannot convert from 'char' to 'char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>g:\oop c++\employee\employee\employee.cpp(13) : error C2440: '=' : cannot convert from 'char' to 'char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>g:\oop c++\employee\employee\employee.cpp(17) : error C2511: 'char Employee::setfirstName(char *) const' : overloaded member function not found in 'Employee'
1> g:\oop c++\employee\employee\employee.h(5) : see declaration of 'Employee'
1>g:\oop c++\employee\employee\employee.cpp(22) : error C2511: 'char Employee::setlastName(char *) const' : overloaded member function not found in 'Employee'
1> g:\oop c++\employee\employee\employee.h(5) : see declaration of 'Employee'
1>g:\oop c++\employee\employee\employee.cpp(27) : error C2556: 'void Employee::getfirstName(char)' : overloaded function differs only by return type from 'const char *Employee::getfirstName(char)'
1> g:\oop c++\employee\employee\employee.h(21) : see declaration of 'Employee::getfirstName'
1>g:\oop c++\employee\employee\employee.cpp(27) : error C2040: 'Employee::getfirstName' : 'void (char)' differs in levels of indirection from 'const char *(char)'
1>g:\oop c++\employee\employee\employee.cpp(28) : error C2065: 'first' : undeclared identifier
1>g:\oop c++\employee\employee\employee.cpp(32) : error C2556: 'void Employee::getlastName(char)' : overloaded function differs only by return type from 'const char *Employee::getlastName(char)'
1> g:\oop c++\employee\employee\employee.h(22) : see declaration of 'Employee::getlastName'
1>g:\oop c++\employee\employee\employee.cpp(32) : error C2040: 'Employee::getlastName' : 'void (char)' differs in levels of indirection from 'const char *(char)'
1>g:\oop c++\employee\employee\employee.cpp(33) : error C2065: 'last' : undeclared identifier
1>g:\oop c++\employee\employee\employee.cpp(39) : error C2065: 'firstName' : undeclared identifier
1>g:\oop c++\employee\employee\employee.cpp(40) : error C2065: 'lastName' : undeclared identifier
1>g:\oop c++\employee\employee\employee.cpp(40) : error C2059: syntax error : ';'
1>Secretary.cpp
1>g:\oop c++\employee\employee\secretary.h(7) : error C2504: 'Employee' : base class undefined
1>g:\oop c++\employee\employee\secretary.cpp(6) : error C2065: 'first' : undeclared identifier
1>g:\oop c++\employee\employee\secretary.cpp(6) : error C2065: 'last' : undeclared identifier
1>g:\oop c++\employee\employee\secretary.cpp(7) : error C2614: 'Secretary' : illegal member initialization: 'Employee' is not a base or member
1>g:\oop c++\employee\employee\secretary.cpp(8) : error C2065: 'sal' : undeclared identifier
1>g:\oop c++\employee\employee\secretary.cpp(18) : error C2511: 'void Secretary::getsalary(int) const' : overloaded member function not found in 'Secretary'
1> g:\oop c++\employee\employee\secretary.h(6) : see declaration of 'Secretary'
1>g:\oop c++\employee\employee\secretary.cpp(24) : error C2065: 'firstName' : undeclared identifier
1>g:\oop c++\employee\employee\secretary.cpp(25) : error C2065: 'lastName' : undeclared identifier
1>g:\oop c++\employee\employee\secretary.cpp(25) : error C2059: syntax error : ';'
1>Driver.cpp
1>g:\oop c++\employee\employee\driver.cpp(9) : error C2470: 'main' : looks like a function definition, but there is no parameter list; skipping apparent body
1>Generating Code...
1>Build log was saved at "file://g:\OOP C++\Employee\Employee\Debug\BuildLog.htm"
1>Employee - 25 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Spelling mistake at 64

Employee::Employee()

70,71

firstName = first;

lastName = last;

You are assigning a character to a character pointer.

An approach would be to change this to take char pointers as input and use a string function to copy.

Allocate memory for the pointers in the constructor.


74-77 variable is mis-spelt. Declaration of functions in Employee.h and Employee.cpp don't match.

Before calling this function make sure that memory is allocated to the firstName pointer.

Employee:: setfirstName (char *fisrt)// should be first
#
{
#
strcpy_s ( firstName, first);
#

Continue like this and get back with corrected code.

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.