I have multiple errors in my code that I was just working on, the errors are as follows:
Here is my build log:
monsters.h:11: error: storage class specified for field `enemyattack'
monsters.h:11: error: ISO C++ forbids initialization of member `enemyattack'
monsters.h:11: error: making `enemyattack' static
monsters.h:11: error: ISO C++ forbids in-class initialization of non-const static member `enemyattack'
monsters.h:12: error: storage class specified for field `enemyhealth'
monsters.h:12: error: ISO C++ forbids initialization of member `enemyhealth'
monsters.h:12: error: making `enemyhealth' static
monsters.h:12: error: ISO C++ forbids in-class initialization of non-const static member `enemyhealth'
monsters.h:13: error: storage class specified for field `enemydefense'
monsters.h:13: error: ISO C++ forbids initialization of member `enemydefense'
monsters.h:13: error: making `enemydefense' static
monsters.h:13: error: ISO C++ forbids in-class initialization of non-const static member `enemydefense'
monsters.h:14: error: missing terminating ' character
monsters.h:15: error: expected primary-expression before '}' token
monsters.h:15: error: storage class specified for field `enemy'
monsters.h:15: error: ISO C++ forbids initialization of member `enemy'
monsters.h:15: error: making `enemy' static
monsters.h:15: error: ISO C++ forbids in-class initialization of non-const static member `enemy'
monsters.h:15: error: expected `;' before '}' token
monsters.h:15: error: expected `;' before '}' token
main.cpp: In function `int main()':
main.cpp:14: error: `enemyhealth' undeclared (first use this function)
main.cpp:14: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:15: error: `enemyattack' undeclared (first use this function)
main.cpp:16: error: `enemydefense' undeclared (first use this function)
And here is my code
main.cpp
#include <iostream>
#include <fstream>
#include <math.h>
#include "monsters.h"
using namespace std;
char enemy[50];
char command[35];
int main() {
system("color 02");
strcpy(enemy,"Nathan Archer");
cout << "Fight with " <<enemy;
cout << "\nHealth: " <<enemyhealth;
cout << "\nAttack: " <<enemyattack;
cout << "\nDefense: " <<enemydefense;
cout << "\n \n \n";
cout << "Commands: \n Attack \n Magick \n Run!";
cout << "\n ====================";
cout << "\n | Command:";
cin.getline(command, 35);
return 0;
}
monsters.h
#include <string>
#ifndef MONSTERS_H
#define MONSTERS_H
struct NArcher {
extern int enemyattack = 10;
extern int enemyhealth = 20;
extern int enemydefense = 5;
extern char enemy = 'Nathan Archer;
} ;
#endif
Thanks ahead of time