Class inheritance problem

I have created multiple classes, some inherited from others.
I have problem with the Class' ContSalariat constructor. It says "'N' was not declared in this scope."
ContNormal inherits the Cont class. This relationship has worked perfectly, so I will not post the Cont header and cpp.
The words are in Romanian, but the structure is pretty easy to read.

Cont Normal:
Header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef CONTNORMAL_H
#define CONTNORMAL_H

#include "Cont.h"


class ContNormal : public Cont
{
    public:
        ContNormal(int, double, string);
        ~ContNormal();
        bool retragere(double);
        bool depunere(double);
        bool get_status();
        void change_status();
    protected:
        bool blocat;
};

#endif // CONTNORMAL_H   


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
#include "ContNormal.h"

ContNormal::ContNormal(int c, double s, string N) : Cont(c, s, N)
{
    blocat = false;
}

ContNormal::~ContNormal()
{
    //dtor
}

bool ContNormal:: retragere(double s)
{
    if (!blocat && s <= sold)
    {
        sold -= s;
        return true;
    }
    return false;
}

bool ContNormal::depunere(double s)
{
    if(!blocat)
    {
        sold += s;
        return true;
    }
    return false;
}

bool ContNormal::get_status()
{
    return blocat;
}

void ContNormal::change_status()
{
    blocat = !blocat;
}


ContSalariat
Header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef CONTSALARIAT_H
#define CONTSALARIAT_H

#include "ContNormal.h"

class ContSalariat : ContNormal
{
    public:
        ContSalariat(int, double, string, double);
        ~ContSalariat();
        bool retragere(double);
    private:
        double salariu;
};

#endif // CONTSALARIAT_H 


Cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "ContSalariat.h"


ContSalariat::ContSalariat(int c, double s, string nume, double sal) : ContNormal(c, s, N)
{
    salariu = sal;
    blocat = false;
}

ContSalariat::~ContSalariat()
{
    //dtor
}

bool ContSalariat:: retragere(double s)
{
    if (!blocat && sold-s >= -3 * salariu)
    {
        sold -= s;
        return true;
    }
    return false;
}
ContNormal::ContNormal(int c, double s, string N) : Cont(c, s, N) 
ContSalariat::ContSalariat(int c, double s, string nume, double sal) : ContNormal(c, s, N)
If you are changing name of variable, change routines which uses it too.
Also you do not need to set blocat to false, ContNormal constructor will do this for you.
Last edited on
thanks and thanks for advice. it worked. i usually get stuck in small things like this one.
Topic archived. No new replies allowed.