Jeeze now a ton of errors popped up here they are and here is the code:
rpg.cpp:14: syntax error before `::' token
rpg.cpp:18: ISO C++ forbids declaration of `rollabilities' with no type
rpg.cpp:19: ISO C++ forbids declaration of `showabilities' with no type
rpg.cpp:20: parse error before `}' token
rpg.cpp:22: syntax error before `::' token
rpg.cpp:26: syntax error before `::' token
rpg.cpp:28: parse error before `;' token
rpg.cpp:28: syntax error before `++' token
rpg.cpp:34: syntax error before `::' token
rpg.cpp:40: ISO C++ forbids declaration of `time' with no type
rpg.cpp:40: `int time' redeclared as different kind of symbol
C:/Dev-Cpp/include/time.h:97: previous declaration of `time_t time(time_t*)'
rpg.cpp:40: invalid conversion from `time_t*' to `int'
rpg.cpp:42: ISO C++ forbids declaration of `srand' with no type
rpg.cpp:42: `int srand' redeclared as different kind of symbol
C:/Dev-Cpp/include/stdlib.h:362: previous declaration of `void srand(unsigned
int)'
rpg.cpp:44: parse error before `for'
rpg.cpp:44: parse error before `;' token
rpg.cpp:44: syntax error before `++' token
Code:
#ifndef _RPG_H_
#define _RPG_H_
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
#include "rpg.h"
Character::Character()
{
Character::ABILITYNAMES={"Strength","Dexterity","Constitution",
"Intelligence","Wisdom","Charisma"};
rollabilities();
showabilities();
}
Character::~Character()
{}
Character::showabilities()
{
for(int i=0;i<6;i++)
{
cout<<abilitynames[i]<<"\t"<<attribs.abilities[i]<<endl;
}
}
Character::rollabilities()
{
const int LOW = 1;
const int HIGH = 100;
time_t seconds;
//Get value from system clock and place in seconds variable.
time(&seconds);
//Convert seconds to a unsigned integer.
srand((unsigned int) seconds);
for(int i=0;i<6;i++)
{
attribs.abilites[i]=rand()%(HIGH-LOW+1)+LOW;
}
}
#endif
Code:
#ifndef _RPG_H_
#define _RPG_H_
#include <string>
class Character
{
public:
Character();
~Character();
void showabilities();
private:
// charachter attributes
static const std::string ABILITYNAMES;
struct attribs
{
std::string name;
std::string profession;
std::string armortype;
std::string race;
int armorclass;
int abilities[6];
int hitpoints;
};
void rollabilities();
};
#endif
Code:
#include <iostream>
#include <stdlib.h>
#include "rpg.h"
using namespace std;
const string Character::ABILITYNAMES;
int main(int argc, char *argv[])
{
Character Player();
system("PAUSE");
return 0;
}