in one of my .cpp classes the prog doesn't realize that i have include iostream and VC++ gives me errors. Here is what I have:
Code:
//===================MAIN.CPP
#include <iostream>
#include <cstdlib>
#include "gridworld.h"
using namespace std;
int main()
{
CGridworld test1(5, 5);
//...AND SO ON
//=====================gridworld.h
// File: gridworld.h
#ifndef _GRIDWORLD_H
#define _GRIDWORLD_H
#include "DLList.h"
#include "personarray.h"
class CGridworld
{
public:
CGridworld(int nrows=5, int ncols=5);//constructor with gridsize
//~CGridworld();
void printMe(int r=5);
void move(int pid, int new_row, int new_col); //move person pid to
// (new_row,new_col)
void printMembers(int i, int j); //print the people in district (i, j)
private:
int **Grid; //two-dimentional array
int nrows; //number of rows in this grid world
int ncols; //number of columns in this grid world
//CPersonArray P; //stores person info
};
#endif
#include "gridworld.cpp"
//====================gridworld.cpp
CGridworld::CGridworld( int nrows, int ncols)
{
Grid = new int*[nrows];
for( int i = 0; i < nrows; i++)
{
Grid[i] = new int[ncols];
}
}
void CGridworld::printMe(int r)
{
for(int j=0; j<r; j++){
cout << Grid[j] << endl;//the problem is here
}
}
so the problem lies in either gridworld.h or .cpp. I'm not sure how to do it exactly. In GCC it seems to work fine?!
axon