Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with a constructor c++

Tags:

c++

So I have this code for these Constructors of the Weapon class:

Weapon(const WeaponsDB * wepDB);
Weapon(const WeaponsDB * wepDB_, int * weaponlist);
~Weapon(void);  

And I keep getting an error:

1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : error C2062: type 'int' unexpected

and ensuing errors (more than listed):

1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(21) : error C2059: syntax error : '('
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(21) : error C2238: unexpected token(s) preceding ';'
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(33) : error C2327: '<unnamed-tag>::maxWeapons' : is not a type name, static, or enumerator
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(33) : error C2065: 'maxWeapons' : undeclared identifier
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(38) : warning C4094: untagged 'class' declared no symbols

I'm a semi-newbie and I haven't been able to figure it out.

Line 21 is the second constructor, the first one doesn't cause an error. Also, if I comment out this constructor I still get all the errors listed after that constructors. Any idea what the problem might be?

Here is the preceding code for reference:

#ifndef Weapon
#define Weapon
#include <allegro.h>
#include <stdio.h>
#include <iostream>

using namespace std;

class WeaponsDB;
class MenuDriver;
class Ammo;

class Weapon
{
public:
.....
like image 502
Chad Avatar asked Nov 28 '22 02:11

Chad


1 Answers

#ifndef Weapon
#define Weapon

This is almost certainly going to cause weirdness; call the constant WEAPON_H instead.

like image 185
Ana Betts Avatar answered Dec 08 '22 05:12

Ana Betts