Nov 11, 2011 at 7:44pm UTC
//Employee.h
#pragma once
#include <string>
class Employee
{
public:
Employee(long id=00000,const std::string &s="",const std::string &d="");
Employee(const Employee&e);
virtual ~Employee(void);
std::string getEmpName() const;
bool operator==(const Employee &e) const;
long getEmpId() const;
std::string getEmpDesig() const;
void setEmpId(long);
void setEmpName(const std::string &);
void setEmpDesig(const std::string &);
virtual void displayEmp() const;
void populate();
long genEmpId();
void buyTckt();
void cancelTckt();
void modifyTckt();
private:
long empId;
std::string empName;
std::string empDesig;
};
//Manager.h
#pragma once
#include "Employee.h"
class Manager:public Employee
{
public:
Manager(long id=00000,const std::string &s="",const std::string &d="");
virtual ~Manager(void);
void displayEmp() const;
private:
static long manId;
};
//Clerk.h
#pragma once
#include "Employee.h"
class Clerk:public Employee
{
public:
Clerk(long id=00000,const std::string &s="",const std::string &d="");
virtual ~Clerk(void);
Clerk (const Clerk & clk);
void buyTckt();
void cancelTckt();
void modifyTckt();
void displayEmp() const;
private:
static long cId;
};
//main.cpp
#include "Employee.h"
#include <iostream>
using namespace std;
int main()
{
Employee *e;
char c;
X:
cout<<"Enter the kind of employee you want to create:"
<<"M: Manager\nC: Clerk"
<<endl;
cin>>c;
if(c=='m' || c=='M')
e=new Manager();
else if(c=='c' || c=='C')
e=new Clerk();
else
{
cout<<"Invalid input!";
goto X;
}
return 0;
}
**************************
Problem: I think there is something wrong with the way I implemented inheritance. Sorry if I made a very silly mistake, this is my first attempt at inheritance in C++. I appreciate any help.
The errors I'm getting are:
main.cpp(16): error C2061: syntax error : identifier 'Manager'
main.cpp(18): error C2061: syntax error : identifier 'Clerk'
Thanks a lot in advance.
Nov 11, 2011 at 8:34pm UTC
I think you should include Manager.h and Clerk.h into your main.cpp file.
Nov 11, 2011 at 10:01pm UTC
You are right tfityo. Thanks for your time. My code runs now.