Thanks guys for your responses. Here is the associated code. I included the header file that is giving the problem. Whenever I run it, I get the LNK 2019 error. I tried copying the header file to my VC 'include' directory but get the same error.
#ifndef CCC_EMPL_H
#define CCC_EMPL_H
#include <string>
using namespace std;
/**
A basic employee class that is used in many examples
in the book "Computing Concepts with C++ Essentials"
*/
class Employee
{
public:
/**
Constructs an employee with empty name and no salary.
*/
Employee();
/**
Constructs an employee with a given name and salary.
@param employee_name the employee name
@param initial_salary the initial salary
*/
Employee(string employee_name, double initial_salary);
/**
Sets the salary of this employee.
@param new_salary the new salary value
*/
void set_salary(double new_salary);
/**
Gets the salary of this employee.
@return the current salary
*/
double get_salary() const;
/**
Gets the name of this employee.
@return the employee name
*/
string get_name() const;
private:
string name;
double salary;
};
#endif
#include <iostream>
using namespace std;
#include "ccc_empl.h"
int main()
{
Employee harry("Hacker, Harry", 45000.00);
Yup you are declaring your class's member functions, but you never define them. Remember with member functions usually they will be defined in a seperate file. Here is a short simple example.
MyClass.h
1 2 3 4 5 6 7 8 9 10
//Class declaration usually go into their own header file.
class MyClass
{
public:
void addToNumber(int addNumber); // This is a declaration
private:
int number;
}
MyClass.cpp
1 2 3 4 5 6 7 8
// All the member function definitions will usually go into a seperate .cpp file.
#include "MyClass.h"
void MyClass::addToNumber(int addNumber) // This is a definition
{
number += addNumber;
}
Now that is just a short example of it and yours will be much more complex probably but it shows the general idea. Basically you have the class declaration but you forgot to write the definition which tells what each member function in your class is suppose to do.
Hope this helps a bit if you have any other questions or don't get anything just let me or someone know and we will try and help you as best we can.