When I attempt to compile, I get " [Linker error] undefined reference to `WarTable:: D6' " and [Linker error] undefined reference to `WarTable:: D3'. I am trying to initialize certain values in my 2 dimensional array to a random number based off of a roll of a D6 or D3.Is there a better way to do this? I originally wrote this program in java and it worked fine but I'm re-writing it in c++ to learn the language better.
I am using Dev-C++ ver4.9
Constructor
WarTable::WarTable()
{
//for a D6 roll
D6 = rand() % 6 + 1;
//for a D3 roll
D3 = rand() % 3 + 1;
}
Variables are defined here in the header file
#ifndef _WARTABLE_H_
#define _WARTABLE_H_
class WarTable
{
public:
//constructor
WarTable();
//D6 roll
static int D6;
//D3 roll
static int D3;
static const int Soldiers[228][10];
static const int Weapons[145][4];
static const int Vehicles[39][8];
};
#endif
Part of array
#include "wartable.h"
const int WarTable::Soldiers[228][10] = {
//ws,bs,s,t,w,i,a,ld,sv
/*Abaddon*/ {7,5,8,5,4,6,4,10,2},
/*Ahriman*/ {5,5,4,4,3,5,3,10,3},
/*Archon*/ {6,6,3,3,3,7,3,9,5},
/*Ard Boy*/ {4,2,3,4,1,2,2,7,4},
/*Aspiring Champion*/ {4,4,4,4,1,4,2,10,3},
/*Aspiring Sorcerer*/ {4,4,4,4,1,4,2,10,3},
Example implementation in the array
/*Chaos Spawn*/ {3,0,5,5,3,3,D6,10,0},
/*Deffguns*/ {7,4,D3},
Any help would be great
This post has been edited by Cheeto: 05 July 2008 - 07:46 PM

New Topic/Question
Reply



MultiQuote






|