所以我有这些武器类构造函数的代码:
Weapon(const WeaponsDB * wepDB);
Weapon(const WeaponsDB * wepDB_, int * weaponlist);
~Weapon(void);
我不断收到错误:
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : error C2062: type 'int' unexpected
和随之而来的错误(比列出的更多):
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
我是一个半新手,一直没弄明白。
第 21 行是第二个构造函数,第一个不会导致错误。 另外,如果我注释掉这个构造函数,我仍然会得到在该构造函数之后列出的所有错误。知道可能是什么问题吗?
以上代码供引用:
#ifndef Weapon
#define Weapon
#include <allegro.h>
#include <stdio.h>
#include <iostream>
using namespace std;
class WeaponsDB;
class MenuDriver;
class Ammo;
class Weapon
{
public:
.....
最佳答案
#ifndef Weapon
#define Weapon
这几乎肯定会引起怪异;而是调用常量 WEAPON_H。
关于c++ - 构造函数c++的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/372714/