Error C2660

closed account (LAfSLyTq)
it says 'battlepahse' : function does not take 0 arguements.

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
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;

	int damageDealt;
	char name[10];
	char Action;
	 
class Boar1;
class Player1;
void battlePhase(Player1 &player, Boar1 &boar);

class Player1
{
public:
    static int health;
    static int exp;
    static int level;
    static int atk;
    Player1 ()
    {
        health = 20;
        level = 1;
        exp = 0;
        atk = 5;
        damageDealt = atk;
    }
};


class Boar1
{
public:
    static int health;
    static int level;
    static int atk;
    Boar1 ()
    {
        health = 20;
        level = 1;
        atk = 5;
    }
};

void battlePhase(Player1 &player, Boar1 &boar)
{
    cout <<"You have run into a Boar!\nWhat do you want to do?\n1=Attack "<<endl;
    cin >> Action;

    if ( Action == '1' || Action == 'i' )
    {
        cout<<name<<" attacked enemy for " <<player.atk<< endl;
        boar.health = boar.health - damageDealt;

        if ( damageDealt < 0 )
        {
            damageDealt = 0;
            cout<<"No damage!"<<endl;
        }
        else if ( damageDealt == 0 )
            cout <<"No damage!"<<endl;
        else if ( damageDealt > 0 )
            cout << "enemy" << " took " << damageDealt << " damage!";

        if(boar.health == 0)
        {
            cout<<"enemy has died!"<<endl;
            cout<<"you have gained "<<"50"<<" exp!"<<endl;
            system ("CLS");
            player.exp += 50;
        }
        else
        {
            cout << "\nThat isn't an action! Try typing '1'.";
            battlePhase(player,boar);
        };
    }
}

int main()
{
battlePhase(); //The error is here.
return 0;
}


any ideas?
you have the function battlePhase set up to take 2 arguments but arent passing it anything hence the error. You should either pass battlePhase a refrence to a Player1 and a Boar1 or you should be able to just declare them in battlePhase and remove them as args from the looks of things.
Last edited on
closed account (LAfSLyTq)
i it to "battlePhase(Player1 &player, Boar1 &boar);" but now everything inside the () is appearently an error, what am i doing wrong.. and try to dumb it dwon for me, im new to this so i dont know C++ talk.
So presumably this is what your main function now looks like:

1
2
3
4
5
int main()
{
battlePhase(Player1 &player, Boar1 &boar);
return 0;
}


The battlephase line there says "I declare the existence of a function named battlePhase, and it takes in two objects, a reference to a Player1 object and a reference to a Boar1 object". You're not calling the function. You're declaring that it exists, except you're not, because there's no return type. It's a mess.

Did you mean to call the function?

1
2
3
4
5
6
7
int main()
{
Player1 player; // CREATE an object of type Player1, named player
Boar1 boar; // CREATE an object of type Boar1, named boar
battlePhase(player, boar); //CALL function, passing in the objects I just created
return 0;
}
Topic archived. No new replies allowed.