undefined reference error

I experience this one problem where the error stated was "undefined reference to `branch::branch(std::string)" for line 75,76,77,78. Hope someone can explain to me about what happened to those declarations. Thanks in advance!

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

class branch {
public:
branch(string);
void randomSales(string l,double qSales[4]);
/*{
    srand(time(0));
    for(int i=0; i<4; i++)
    {
        qSales[i] = rand()%2001;
    }
}*/

double getTotal(string l,double qSales[4]);
/*{
    double totalSales = 0.0;
    for(int i=0; i<4; i++)
    {
        totalSales+=qSales[i];
    }
return totalSales;
}*/
void display(string l,double t,double qSales[4]);
/*{
    cout << " the sales for " << l << " are : ";
    for(int i=0; i<4; i++){
        cout << qSales[i] << " ";
    }
    cout << " total sales for " << l << " is " << t << endl;
}*/

private:
    string location;
    double qSales[4];
    double totalSales;

};

void branch::randomSales(string l,double qSales[4])
{
    srand(time(0));
    for(int i=0; i<4; i++)
    {
        qSales[i] = rand()%2001;
    }
}

double branch::getTotal(string l,double qSales[4])
{
    double totalSales = 0.0;
    for(int i=0; i<4; i++)
    {
        totalSales+=qSales[i];
    }
return totalSales;
}

void branch::display(string l,double t,double qSales[4])
{
    cout << " the sales for " << l << " are : ";
    for(int i=0; i<4; i++){
        cout << qSales[i] << " ";
    }
    cout << " total sales for " << l << " is " << t << endl;
}

int main()
{   double qSales1[4],qSales2[4],qSales3[4],qSales4[4];
    int a,b,c,d;
    branch b1("Mid Valley");
    branch b2("One Utama");
    branch b3("Sunway Pyramid");
    branch b4("pavilion");

    b1.randomSales("Mid Valley",qSales1);
    b2.randomSales("One Utama",qSales2);
    b3.randomSales("Sunway Pyramid",qSales3);
    b4.randomSales("pavilion",qSales4);

    a = b1.getTotal("Mid Valley",qSales1);
    b = b2.getTotal("One Utama",qSales2);
    c = b3.getTotal("Sunway Pyramid",qSales3);
    d = b4.getTotal("pavilion",qSales4);

    b1.display("Mid Valley",a,qSales1);
    b2.display("One Utama",b,qSales2);
    b3.display("Sunway Pyramid",c,qSales3);
    b4.display("pavilion",d,qSales4);

    return 0;
}
'coz your ctor is declared (line 9) but not defined, try something like:
branch(string loc) : location (loc){}
Topic archived. No new replies allowed.