HELP!

Hello,
Currently I'm reading a book on c++ programming and one thing doesnt go right for me! I need to separate class's implementation from interface.

I currently have this code:

salesperson.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 #ifndef SALESPERSON_H_INCLUDED
#define SALESPERSON_H_INCLUDED

class salesperson
{
public:
    salesperson();
    void getsale();
    void setsales(int, double);
    void printannual();
    void printaverage();
    static const int year=13;
private:
    double totalsales();
    double annualsales[year];
    double averagesales();

};

#endif 


salesperson.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <iomanip>
#include "salesperson.h"
using namespace std;

salesperson::salesperson()
{
    for (int i=1; i<=12; i++)
        anualsales=0;
}

void salesperson::getsale()
{
    double holder;
    for (int i=1; i<=year; i++)
    {
        cout<<"Enter sales ammount for "<<i<<" month: ";
        cin>>holder;
        setsales(i, holder);
    }
}

void salesperson::setsales (int month, double holder)
{
    if (month>=1&&month>=12&&holder>0)
        annualsales[month]=holder;
    else cout<<"\nSomething went wrong!\n";
}

void salesperson::printannual()
{
    cout<<"\nThe total annual sales are "<<setw(6)<<totalsales()<<"$\n";
}

void salesperson::printaverage()
{
    cout<<"\nThe average sales are "<<setw(6)<<averagesales()<<"$\n";
}

double salesperson::totalsales()
{
    double holder=0;
    for (int i=1; i<=year; i++)
        holder+=annualsales[i];
    return holder;
}

double salesperson::averagesales()
{
    double holder=0;
    for (int i=1; i<=year; i++)
        holder+=annualsales[i];
    return holder/year;
}


And my program sales.cpp
1
2
3
4
5
6
7
8
9
10
#include "salesperson.h"

int main()
{
    salesperson sim;
    sim.getsale();
    sim.printannual();
    sim.printaverage();
    return 0;
}


But when I try to compile it, I come up with this:

undefined reference to 'salesperson::getsale()'
undefined reference to 'salesperson::salesperson()'
undefined reference to 'salesperson::printannual()'
undefined reference to 'salesperson::printaverage()'


What should I do? Any suggestions?
Thanks,
Rimvydas :)
Linker errors. You have to include the object file created from salesperson.cpp in the linking stage.
How are you running the code or better to ask what IDE are you using?
Do i need to include like this?:
#include "salesperson.cpp"
I'm using CodeBlocks
Topic archived. No new replies allowed.