Reputation: 681
I am getting an error on this line:
Attack a("Nothing", 60, Magic);
Here is the error:
..\main.cpp:11: error: expected `;' before "a"
..\main.cpp:11: warning: statement has no effect
Here are the relevant files: main.cpp:
#include "Attack.h"
int main() {
Attack a("Nothing", 60, Magic);
return 0;
}
Attack.h:
#ifndef ATTACK_H_
#define ATTACK_H_
#include <string>
#include <stdlib.h>
#include <time.h>
enum ATTACK_ATTRIBUTE {
Attack, Speed, Magic
};
class Attack {
private:
std::string name;
int power; //Out of 10
ATTACK_ATTRIBUTE attribute;
public:
Attack(std::string name, int power, ATTACK_ATTRIBUTE attribute);
virtual ~Attack();
std::string getName();
ATTACK_ATTRIBUTE getAttribute();
int getPower();
};
#endif /* ATTACK_H_ */
Upvotes: 2
Views: 95
Reputation: 13945
You have a class and an enumerator both called 'Attack'. Try changing one of the names to something else.
Upvotes: 5
Reputation: 264381
The enum value Attack is in the same namespace as Attack the class and they are conflicting.
Upvotes: 2
Reputation: 69
You have defined your Attack class in a header file but I don't see an implementation for it. Don't you need to implement the class methods?
Upvotes: -1