Here is my code so far...
Code: Select all
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
class object{
//object base class
int XMAX;
int YMAX;
public:
void set_char(char character);
char r_char();
char grid[YMAX][XMAX]; //Im trying to define YMAX and XMAX when the object is declared in the main function
char* pgrid[YMAX][XMAX];
protected:
int x;
int y;
int ox;
int oy;
char ch;
};
void object::set_char(char character){
ch=character;
}
char object::r_char(){
return ch;
}
class screen:public object{
public:
void rend(char* a[YMAX][XMAX]);
};
void screen::rend(char* a[YMAX][XMAX]){
*pgrid[oy][ox]=' ';
*pgrid[y][x]=ch;
}
int main(){
object a(10,10); //now the array is supposed to be grid[10][10];
}
1>h:\headers\mvglib.h(21) : error C2327: 'object::YMAX' : is not a type name, static, or enumerator
1>h:\headers\mvglib.h(21) : error C2065: 'YMAX' : undeclared identifier
How can i change the size of the array for each declaration of the object?