96 errors, compiling after 3 days of work is a bad idea.


Please help me again, i now see why you try and compile may sooner than a couple days into a project. tried compiling today and got 96 errors, these are the first few that confuse me. as far as I understand, they shouldn't be here but obviously i've done something wrong.

Error C2660 'Monster::init': function does not take 11 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 28

Error C2660 'Monster::init': function does not take 11 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 29

Error C2660 'Monster::init': function does not take 11 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 30

Error C2660 'Player::makeAttack': function does not take 3 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 42

Error C2371 'turn': redefinition; different basic types C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 51

Error C3646 'targetList': unknown override specifier C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2143 syntax error: missing ',' before '[' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2143 syntax error: missing ')' before ';' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2238 unexpected token(s) preceding ';' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C3646 'targetList': unknown override specifier C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2143 syntax error: missing ',' before '[' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2143 syntax error: missing ')' before ';' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9

Error C2238 unexpected token(s) preceding ';' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.h 9



Combat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 #pragma once
class Combat
{
public:
	Combat();
	
	bool runCombat();

	string targetList[];


private:
	int checkSpeed(int crea1, int crea2, int crea3, int crea4);
};



Combat.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"

using namespace std;



Combat::Combat()
{
}


bool Combat::runCombat()
{
	Player kyle;

	Monster enemies[3];

	Monster one = enemies[0];
	Monster two = enemies[1];
	Monster three = enemies[2];
	
	kyle.init(1, 10, 10, 3, 5, 6, 15, 12, 500, 1000);
	one.init("Orrin", 1, 10, 10, 2, 5, 6, 15, 12, 500, 1000);
	two.init("Braedon", 1, 10, 10, 1, 5, 6, 15, 12, 500, 1000);
	three.init("Brent", 1, 10, 10, 4, 5, 6, 15, 12, 500, 1000);

	int speed1 = kyle.accessSpeed();
	int speed2 = one.accessSpeed();
	int speed3 = two.accessSpeed();
	int speed4 = three.accessSpeed();

	int turn = checkSpeed(speed1, speed2, speed3, speed4);

	if (turn == 1) {
		int choice = kyle.pickAction();
		if (choice == 1) {
			kyle.makeAttack(one, two, three);
		}
	}
	
	else {
		//bigger.pickAction();
	}


	char turn = 'a';

}

int Combat::checkSpeed(int crea1, int crea2, int crea3, int crea4)
{
	if (crea1 > crea2 && crea3 && crea4) {
		return 1;
	}
	else if (crea2 > crea1 && crea3 && crea4) {
		return 2;
	}
	else if (crea2 > crea1 && crea3 && crea4) {
		return 3;
	}
	else {
		return 4;
	}
}


player.h
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
#pragma once
class Player
{
public:
	Player();
	void init(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int gold, int experience);

	void slot(Weapon _weapon);

	int accessSpeed();

	int pickAction();

	void makeAttack(Monster &target1, Monster &target2, Monster &target3);

	int _level;
	int _health;
	int _defense;
	int _speed;
	int _damage;
	int _attack;
	int _stamina;
	int _mana;
	int _gold;
	int _experience;

	Dice _wAttDice;
	Dice _wDamDice;

private:
	

	int pickTarget();

	
};



Player.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "Player.h"
#include <iostream>
#include "Monster.h"
#include "Time.h"
#include <ctime>
#include <string>
#include "Dice.h"
#include "Weapon.h"

using namespace std;


Player::Player()
{
}

void Player::init(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int gold, int experience)
{
	_level = level;
	_health = health;
	_defense = defense;
	_speed = speed;
	_damage = damage;
	_attack = attack;
	_stamina = stamina;
	_mana = mana;
	_gold = gold;
	_experience = experience;
}

void Player::slot(Weapon _weapon)
{
	_weapon._attackDice = _wAttDice;
	_weapon._damageDice = _wDamDice;
	_weapon._name;
}

int Player::accessSpeed()
{
	return _speed;
}

int Player::pickAction()
{
	whoops:
	int actionChoice;

	cout << "please pick an action!" << endl;
	cout << "1). Attack!" << endl;
	cout << "2). Cast Spell!" << endl;

	cin >> actionChoice;


	if (actionChoice == 1) {
		return 1;
	}
	else if (actionChoice == 2) {
		//Spell function
	}
	else {
		//Need to make this loop for invalid choice.
		cout << "You cannot do that now!" << endl;
		goto whoops;
	}

}

void Player::makeAttack(Monster &target1, Monster &target2, Monster &target3)
{
	

	//Pick Weapon
	int wDamage = _damage;
	int wAttack = _attack;
	Dice damDice = _wDamDice;
	Dice attDice = _wAttDice;
	int dTotal;
	
	Dice roll;

	//Pick target
	cout << "Please pick a target" << endl;
	cout << target1.name << endl;
	cout << target2.name << endl;
	cout << target3.name << endl;
	int choice;
	cin >> choice;

	switch (choice)
	{
	case 1:
		if ((wAttack + roll.d6) >= target1._defense) {
			(wDamage + roll.d8 - target1._armor) = dTotal;
			target1._health = -dTotal;
			cout << "You have dealt " << dTotal << "damage to " << target1.name << "!" << endl;
		}
		else {
			cout << "You're attack has missed!" << endl;
		}
		break;
	case 2:
		if ((wAttack + roll.d6) >= target2._defense) {
			(wDamage + roll.d8 - target2._armor) = dTotal;
			target2._health = -dTotal;
			cout << "You have dealt " << dTotal << "damage to " << target2.name << "!" << endl;
		}
		else {
			cout << "You're attack has missed!" << endl;
		}
		break;
	case 3:
		if ((wAttack + roll.d6) >= target3._defense) {
			(wDamage + roll.d8 - target3._armor) = dTotal;
			target3._health = -dTotal;
			cout << "You have dealt " << dTotal << "damage to " << target3.name << "!" << endl;
		}
		else {
			cout << "You're attack has missed!" << endl;
		}
		break;
	}

	//apply damage

	//end action

}

int Player::pickTarget()
{

}



monster.h
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
#pragma once
class Monster
{
public:
	Monster();
	void init(string name, int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist);

	int accessSpeed();

	string _name;

	int _level;
	int _health;
	int _defense;
	int _speed;
	int _damage;
	int _attack;
	int _stamina;
	int _mana;
	int _armor;
	int _magicResist;

private:
};



monster.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
#include "Monster.h"
#include <string>
#include <iostream>

using namespace std;



Monster::Monster()
{
}


void Monster::init(string name, int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist)
{
	_name = name;
	_level = level;
	_health = health;
	_defense = defense;
	_speed = speed;
	_damage = damage;
	_attack = attack;
	_stamina = stamina;
	_mana = mana;
	_armor = armor;
	_magicResist = magicResist;
}

int Monster::accessSpeed()
{
	return _speed;
}





I don't write .h files but is }; the proper way to end them?
combat.h line 9

string target[];

If your tring to make an array here you need some info in the [].

I don't write .h files but errors are pointing here. When I write an array it looks more like this in a cpp file.

const int MAX_TARGET = 128;

string target[MAX_TARGET];

I can't help much with the const int thing I'm tring to get some help with that too.

I hope I helped or pointed you in the right direction.
Last edited on
I haven't learned how to use more than one file yet either.
That isn't ending a .h file it is ending a class definition.
combat.cpp:51, you define turn as a character when above you have already defined it as a integer.

combat.h:9, as mentioned above, your array must have a size. If you want a dynamically resizing container, you may try a vector or something similar.

Try fixing those problems and see if the errors are resolved.
Combat.cpp line 37

you set int turn on line 37.

Then line 51 you got char turn = 'a';

This is the redefinition error.

You can't set int turn and then latter set char turn you have to name it different like turn1 or something.
Last edited on
Combat.cpp line 42

kyle.makeAttack(one, two, three);

The error say this dosnt take 3 arguments. You got three one, two, three

I can't tell you how to fix this but three is too many. Try two?

that's a bad answer I know but I really don't know what kyle.makeAttack is so I don't know how to set it.

Oh I get it now. Kyle is the player and makeAttack is the function. I'm not very sharp with class programming. ;)
Last edited on
Combat.cpp line 28,29,30

This is you main problem with the too many arguments I would think. Focus here and when this is fix it could also fix the error on line 42.

One thing I notice is its a init and your mixing string and data. If you look at line 27 your doing the same thing but only using data. there's no error with line 27 so you may need to get rid of the strings.

kyle.init(1, 10, 10, 3, 5, 6, 15, 12, 500, 1000);
one.init("Orrin", 1, 10, 10, 2, 5, 6, 15, 12, 500, 1000);
two.init("Braedon", 1, 10, 10, 1, 5, 6, 15, 12, 500, 1000);
three.init("Brent", 1, 10, 10, 4, 5, 6, 15, 12, 500, 1000);
Topic archived. No new replies allowed.