compiling a class

From: Edo (edwardoJE_at_aking.com)
Date: 06/05/04


Date: Fri, 04 Jun 2004 17:40:15 -0700

Hello
I am not sure why this is giving the errors below when compiling

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

Employee::Employee(string Name = "No Name",
string Id = "000-00-0000") : _name(Name), _id(Id) {}

string Employee::getName(void){return _name;}
string Employee::getId(void){return _id;}
void Employee::setName(string Name){_name = Name;}
void Employee::setId(string Id){_id = Id;}

int main()
{
     cout << john.getName() << endl;
     cout << john.getid() << endl;
        cout << "setid to 008 and name to alosh"<<endl;
        john.setid("00448");
        john.setName("alosh");
     cout << john.getid() <<endl;
        cout << john.getName()<< endl;
     return 0;
}

//***************************************
//Employee.h
#include <iostream>
#include <string>
using namespace std;

class Employee {
public:
        Employee();
     string getName(void);
     void setName(string);
     string getId(void);
     void setId(string);
private:
     string _name;
     string _id;
};
//*****************************************
Employee.cpp:8: error: prototype for `
Employee::Employee(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)' does not match any in class `Employee'
Employee.h:6: error: candidates are: Employee::Employee(const Employee&)
Employee.h:8: error: Employee::Employee()
Employee.cpp: In function `int main()':
Employee.cpp:17: error: `john' undeclared (first use this function)
Employee.cpp:17: error: (Each undeclared identifier is reported only
once for
each function it appears in.)



Relevant Pages