Question about classes and structures.
I am making the base values for the stats for each race in my text base rpg. Right now I have a stucture set up for it, which I though would be able to house all the information. Either I do not understand how class's and structures work or its not meant to do what I am wanting it to do. Here is what I have so far:
Code:
struct RaceStats {
int h_basehp;
int h_basemp;
int h_basestr; // h = human
int h_baseagi;
int h_basearmor;
int e_basehp;
int e_basemp; // e = enchanter
int e_basestr;
int e_baseagi;
int e_basearmor;
int b_basehp;
int b_basemp; // b = brute
int b_basestr;
int b_baseagi;
int b_basearmor;
};
I found out that I can not initialize the values of these variables from inside the structure without getting an error. I tried this
Code:
struct RaceStats {
int h_basehp = 200;
}
and it gives me an error.
ISO C++ forbids initialization of member `h_basehp'
So I assume either I am doing it wrong or you just cant initialize values from inside the structure. Which would defeat the whole purpose of me using a structure.
Im I just doing it wrong or would it be better to just make these in the global scope and give them values like this?
Code:
#include <iostream>
using namespace std;
int h_basehp = 200;
int main {
//code here
}