Hi
I have made av simple class calles "nationclass". In the header file I define it like this:
#ifndef NATIONCLASS_H
#define NATIONCLASS_H
class nationclass
{
public:
nationclass();
~nationclass();
void init( );
int ICBMbigCount, ICBMmediumCount, ICBMsmallCount;
private:
};
#endif
My .cpp file looks like this:
#include "nationclass.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
nationclass::nationclass( )
{
ICBMsmallCount = 0;
ICBMmediumCount = 0;
ICBMbigCount = 0;
}
nationclass::~nationclass()
{
}
void nationclass::init ( )
{
int i;
for (i=0; i < 3; i++)
{
int r;
r = (rand() % 3) + 1;
switch (r)
{
case 1:
{
ICBMsmallCount++;
break;
}
case 2:
{
ICBMmediumCount++;
break;
}
case 3:
{
ICBMbigCount++;
break;
}
}
}
}
It all compiles fine but when I try to call the memberfunction init() it says that the public ints ICBMbigCount, ICBMmediumCount and ICBMsmallCount cannot be evaluated. (Access violation reading location 0x00000000).
Can anybody see what I'm doing wrong?