How can I fix this class or possibly make it easier on myself?

I am trying to make a function in a class. I am having troubles with it because it is giving me the error, "no matching function for call to 'CMonster::CMonster()'" Could someone please help? This is what I have so far...
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
class CMonster
{
    protected:
    int health, mana, stamina;
    public:

    CMonster(int _y, int _x)
    {
        setx(_x);
        sety(_y);
    }

    ~CMonster()
    {}

    void setx(int _x)
    {
        x = _x;
    }

    void sety(int _y)
    {
        y = _y;
    }

    int getx()
    {
        return x;
    }

    int gety()
    {
        return y;
    }

    void set_values(int a, int b, int c)
    {
        health=a;
        mana=b;
        stamina=c;
    }
};

class CFurbolg: public CMonster
{
    public:
    int gethealth()
    {
        return health;
    }
    int getmana()
    {
        return mana;
    }
    int getstamina()
    {
        return stamina;
    }
};

class CContainer
{
    CFurbolg furbolgContainer[2];
    CContainer()
    {
        createContainer();
    }

    ~CContainer()
    {}

    void createContainer()
    {
        monsterContainer[0] = CMonster(6, 7);
    }

    void moveMonster(int _index)
    {
        furbolgContainer[_index].sety[y - 1]
    }
};
Add a default constructor (CMonster::Cmonster() //no args ) that initializes the classes members to 0 or whatever. Or just make sure you call the right constructor when you create CMonster's.
Any time you define a constructor for a class you have to include an explicit default constructor. On a side note, a constructor that has default arguments for all of its parameters counts as a default constructor. ;)
Topic archived. No new replies allowed.