Sorry, here's the code surrounding my CHARACTER class.
Here is the character.h
Code:
#ifndef CHARACTER_H
#define CHARACTER_H
#include <iostream>
#include <string>
using namespace std;
class CHARACTER
{
public:
CHARACTER(); //Default constructor
//Overloaded constructor with parameters
CHARACTER(string new_name, int new_location, int new_nation, int new_comm_rank, int new_age_rank, int new_mage_rank, int new_emi_rank, int new_doubled, bool new_dragon);
//Copy constructor
CHARACTER(const CHARACTER &character);
void set_char_name(string name);
//Sets the name af a character to the string szWord.
void set_char_loc(int location);
//Sets the location af a character to the int location.
void set_char_nation(int nation);
//Sets the nation af a character to the int nation.
void set_char_double(int nation);
//Sets the nation af a character to the int nation.
void set_char_com(int comm_rank);
//Sets the comm_rank af a character to the passed-in int.
void set_char_age(int age_rank);
//Sets the age_rank af a character to the passed-in int.
void set_char_mage(int mage_rank);
//Sets the mage_rank af a character to the passed-in int.
void set_char_emi(int emi_rank);
//Sets the emi_rank af a character to the passed-in int.
void set_dragon(bool dragon);
//set to false or true whether the character is a dragon
private:
string name;
int location, nation, comm_rank, agent_rank, mage_rank, emi_rank, doubled;
bool dragon;
};
#endif
Here is the character.cpp
Code:
#include "character.h"
// The default constructor
CHARACTER::CHARACTER()
{
set_char_name("");
set_char_loc(0);
set_char_nation(0);
set_char_double(0);
set_char_com(0);
set_char_age(0);
set_char_mage(0);
set_char_emi(0);
set_dragon(false);
}
CHARACTER::CHARACTER(string new_name, int new_location, int new_nation, int new_comm_rank, int new_age_rank, int new_mage_rank, int new_emi_rank, int new_doubled, bool new_dragon)
{
set_char_name(new_name);
set_char_loc(new_location);
set_char_nation(new_nation);
set_char_double(new_doubled);
set_char_com(new_comm_rank);
set_char_age(new_age_rank);
set_char_mage(new_mage_rank);
set_char_emi(new_emi_rank);
set_dragon(new_dragon);
}
CHARACTER::CHARACTER(const CHARACTER &character)
{
set_char_name(character.name);
set_char_loc(character.location);
set_char_nation(character.nation);
set_char_double(character.doubled);
set_char_com(character.comm_rank);
set_char_age(character.agent_rank);
set_char_mage(character.mage_rank);
set_char_emi(character.emi_rank);
set_dragon(character.dragon);
}
void CHARACTER::set_char_name(string new_name)
//Sets the name af a character to the string szWord.
{
name = new_name;
}
void CHARACTER::set_char_loc(int new_location)
//Sets the location af a character to the int location.
{
location = new_location;
}
void CHARACTER::set_char_nation(int new_nation)
//Sets the nation af a character to the int nation.
{
nation = new_nation;
}
void CHARACTER::set_char_double(int new_doubled)
//Sets the nation af a character to the int nation.
{
doubled = new_doubled;
}
void CHARACTER::set_char_com(int new_comm_rank)
//Sets the comm_rank af a character to the passed-in int.
{
comm_rank = new_comm_rank;
}
void CHARACTER::set_char_age(int new_age_rank)
//Sets the age_rank af a character to the passed-in int.
{
agent_rank = new_age_rank;
}
void CHARACTER::set_char_mage(int new_mage_rank)
//Sets the mage_rank af a character to the passed-in int.
{
mage_rank = new_mage_rank;
}
void CHARACTER::set_char_emi(int new_emi_rank)
//Sets the emi_rank af a character to the passed-in int.
{
emi_rank = new_emi_rank;
}
void CHARACTER::set_dragon(bool new_dragon)
//set to false or true whether the character is a dragon
{
dragon = new_dragon;
}
As you can see nothing very complicated at all. Now what I want to do in my main.cpp is to create a vector of my character CLASS that initially has a size of 10.
Here is my attempt which keeps throwing back the syntax error that I've specified in my first post. as you can see there is nothing really here....I'm simply trying to declare this vector at present, so that the vector has 10 instances of the CHARACTER class, all of which have been created using my default constructor.
Sorry for not posting this earlier.
Cheers
Starkhorn
Code:
#include "character.h"
int main(int argc, char *argv[])
{
vector<CHARACTER> char_list(10);
return 1;
}