Hi, I am writing a program for my C++ class that must create a struct(Hero) and make an array of it. My class is using the lvp library and i was wondering if anybody could help me make a vector of hero objects.
This is what i have so far:
#include<iostream.h>
#include<lvp\string.h>
#include<lvp\vector.h>
#include<lvp\random.h>
struct Hero
{
Hero();
Hero(String n, String c, String r, int h, int s, int d, int co, int w, int ch, int i,vector<String> e);
Hero(String n, String c, String r);
String Name;
String Class;
String Race;
int HitPoints;
int Strength;
int Dexterity;
int Constitution;
int Wisdom;
int Charisma;
int Intelligence;
vector<String> Equipment;
int NumItems;
};
Hero::Hero()
:Name(""),Class(""),Race(""),HitPoints(1+random(20)),Strength(1+random(20)),Dexterity(1+random(20)),Constitution(1+random(20)),Wisdom(1+random(20)),Charisma(1+random(20)),Intelligence(1+random(20))
{
}
Hero::Hero(String n, String c, String r, int h, int s, int d, int co, int w, int ch, int i,vector<String> e)
:Name(n),Class(c),Race(r),HitPoints(h),Strength(s),Dexterity(d),Constitution(co),Wisdom(w),Charisma(ch),Intelligence(i)
{
Equipment.resize(e.length());
for(int i=0;i<Equipment.length();i++)
Equipment[i]=e[i];
NumItems=Equipment.Length;
}
Hero::Hero(String n, String c, String r)
:Name(n),Class(c),Race(r),HitPoints(1+random(20)),Strength(1+random(20)),Dexterity(1+random(20)),Constitution(1+random(20)),Wisdom(1+random(20)),Charisma(1+random(20)),Intelligence(1+random(20))
{
}
int main()
{
randomize();
return(0);
}