Im really trying to do this c++ stuff and I need someone to really help me. My yahoo is eyestolethis. If someone could please come on yahoo and message me and try to help me that would be great. I have the code already written for the program I created, 3D Minesweeper, I would post it all on here but that really will not help me I need someone I can talk to one on one to do me a favor because my comp is stupid.

Just post your code here and we might be able to help you (use code tags, indentation, and don't use void main ). The mods here don't like it when you post your email address and get it off-site, so don't be suprised if they snip your Yahoo address...

Thanks.

this is what i need help with, thereason why i didnt wanna post it is cause i dont want no one stealing my game code and plus as you see its really long, and i mean long. but im at home and i cant drive back to school and i wanted to know if this code works. like are you able to play the game, does some of it come out in color, etc. my comp is stupid and never lets me download stuff to my comp, i have tried downloading many c++ compiliers and it never downloads. so pretty much i just need someone to tell me it works or not. if not if they can help me with the errors, by either telling me or if they fix them but still tell me so i know what i did wrong or show me at least. im trying my hardest to learn this stuff and my advisor through me in a class where normal people would have takin two other c++ courses before this one. i took a java class but she never told this one she put me in was c++ so i pretty much started off with nothing.

//****************************************************************************//
//****************************************************************************//
//**** Program Name: Project1 Minesweeper ****//
//**** File: Minesweeper.cpp ****//
//**** Input Files: created by the user ****//
//**** Output Files: None; output is sent to the terminal screen ****//
//**** Modules Used: conio.h ****//
//**** iostream ****//
//**** Purpose: This program was created to make a 3-Dimensional ****//
//**** Minesweeper, that can be up-sized and down-sized ****//
//**** at anytime. ****//
//****************************************************************************// //
//****************************************************************************//
 
#include <iostream>    //For console output
#include <conio.h>    //For non-standard screen functions
#include <iostream>
#include <windows.h>   // WinApi header
 
using namespace std;
 
 
#define EMPTY_CELL     177
#define CURSOR     1
#define TAIL     219
#define NUM     6
 
 
class Room {
 
private:
     bool visited;
     bool active;
 
public:
     Room(); // Default Constructor
     Room(bool vis, bool act); // Overloaded Constructor
     Room(const Room& node); //  Copy Constructor
     Room& operator= (const Room& node); // Operator
     ~Room(); //  Destructor/Destroyer
 
//Mutators
     void setActive (); // Gets console ready to draw minesweeper grid
     char draw; // Draws the grid for minesweeper
 
};
 
Room::Room () {
     this->visited = false;
     this->active = false;
}
 
Room::Room (bool visited, bool active) {
     this->visited = visited;
     this->active = active;
}
 
Room::Room (const Room& node) {
     this->visited = node.visited;
         this->active = node.active;
}
 
Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}
 
 
void Room::setActive () {
     this->visited = true;
     this->active = true;
}
 
 
char Room::draw () {
     char ch = char (EMPTY_CELL);
     if (visited) {
          ch = char (TAIL);
     }
     if (this-> active) {
          ch = char (CURSOR);
          this-> active = false;
     }
     return ch;
}
 
 
Room::~Room () {
 
}
/*******************************************************************************/
/*******************************************************************************/
 
 
#define LEFT_UPPER_CORNER    201
#define VERTICAL_LINE    186
#define HORIZONTAL_LINE     205
#define RIGHT_UPPER_CORNER     187
#define LEFT_LOWER_CORNER     200
#define RIGHT_LOWER_CORNER     188
#define INTERSECTION     206
#define VERTICAL_WITH_RIGHT_TURN     204
#define VERTICAL_WITH_LEFT_TURN     185
#define HORIZONTAL_WITH_DOWN_LINE     203
#define HORIZONTAL_WITH_UP_LINE     202
#define RROW 11;
#define RCOL 11;
 
class Dynamic3DArray {
 
protected:
         int ROW;
     int COL;
     int DEPTH;
     Room *** array;
 
public;
     Dynamic3DArray (); // Default Consturtor
     Dynamic3DArray (int row, int col, int depth); // Overloaded Con.
     Dynamic3DArray (const Dynamic3DArray& dynamic3DArray);
     Dynamic3DArray& operator= (const Dynamic3DArray& dynamic3DArray); //Assignment Operator
     ~Dynamic3DArray (); //Destroyer/Destructor
 
//Accessors
     int getROW (); //Gets the number of rows
     int getCOL (); //Gets the number of columns
     int getDEPTH (); //Gets the number for the depth
 
//Mutators
     void create (); //Will create a 3Dimentional grid
     void destroy (); //Destroys the grid to free memory
     void setActive (int x, int y, int z); //Will make the cells visited
     bool setDimentions (); //Will set the dimentions of the grid
     void resize (int x, int y, int z); //change the dimentions of the grid
     void print (int depth); //prints the grid with the depth given by user
     void printDimentions (intx, int y, int z); //This prints the overall grid
};
 
Dynamic3DArray::Dynamic3DArray () {
     this-> ROW = 0;
     this-> COL = 0;
     this-> DEPTH = 0;
     array = NULL;
}
 
 
void Dynamic3DArray::create () {
     array = new Room** [ROW];
     for (int r=0; r<ROW; r++) {
          array[r] = new Room* [COL];
          for (int c=0; c<COL; c++) 
     array[r][c] = new Room[DEPTH];
      }
}
 
 
void Dynamic3DArray::destroy () {
     for (int r=0; r<Row; r++) {
          for (int c=0; c<COL; c++)
     delete [] array [r][c];
     delete [] array [r];
      }
     delete [] array;
}
 
 
Dynamic3DArray::Dynamic3DArray (int row, int col, int depth) {
     this-> ROW = row;
     this-> COL = col;
     this-> DEPTH = depth;
     create ();
}
 
 
Dynamic3DArray::Dynamic3DArray (const Dynamic3DArray& dynamic3DArray) {
     this-> ROW = dynamic3DArray.ROW;
     this-> COL = dynamic3DArray.COL;
     this-> DEPTH = dynamic3DArray.DEPTH;
     create ();
}
 
 
void Dynamic3DArray:: setActive (intx, int y, int z) {
     this-> array[x-1][y-1][z-1].setActive ();
}
 
 
void Dynamic3DArray::printDimentions (int x, int y, int z) {
     cout << "            < " << x << "," << y << "," << z << ">" << endl << endl;
}
 
 
void Dynamic3DArray::resize (int r, int c, int d) {
     Dynamic3DArray temp (*this);
     temp = *this;
     this-> destroy ();
     this-> ROW = r;
     this-> COL = c;
     this-> DEPTH = d;
     this-> create ();
     if (temp.ROW<ROW) {
          for (int r=0; r<temp.ROW; r++) {
     for (int c=0; c<temp.COL; c++) {
                     for (int d=0; d<temp.DEPTH; d++)
                     this->array[r+1][c+1][d+1]=temp.array[r][c][d];
     }
          }
     }
}
else
     for (int r=0; r<ROW; r++) {
          for (int c=0; c<COL; c++) {
               for (int d=0; d<DEPTH; d++)
               this->array[r][c][d]=temp.array[r+1][c+1][d+1];
          }
     }
}
 
int Dynamic3DArray::getROW () {
     return this-> ROW;
}
 
int Dynamic3DArray::getCOL () {
     return this-> COL;
}
 
int Dynamic3DArray::getDep () {
     return this->DEPTH;
}
 
Dynamic3DArray::~Dynamic3DArray () {
     destroy ();
}
 
Dynamic3DArray& Dynamic3DArray::operator=(const Dynamic3DArray& dynamic3DArray) {
     destroy ();
     this->ROW = dynamic3DArray.ROW;
     this->COL = dynamic3DArray.COL;
     this->DEPTH = dynamic3DArray.DEPTH;
     create ();
     for (int r=0; r<ROW; r++) {
          for (int c=0; c<COL; c++) {
               for (int d=0; d<DEPTH; d++)
               array[r][c][d]=dynamic3DArray.array[r][c][d];
          }
     }
      return *this;
}
 
void Dynamic3DArray::print (int depth) {
     system ("cls");
     cout << char (LEFT_UPPER_CORNER);
     for (int r=0; r<ROW; r++) {
          cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_DOWN_LINE);
     }
     cout << "\b" << char (RIGHT_UPPER_CORNER) << endl;
     for (int c=0; c<COL; c++) {
          cout << char (VERTICAL_LINE);
          for (int r=0; r<ROW; r++) {
               cout << array[r][c][depth-1].draw() << char (VERTICAL_LINE);
     }
     cout << "\b" << char (VERTICAL_WITH_RIGHT_TURN);
     if (c< (COL-1)) {
          for (int i=0; i<ROW; i++) {
               cout << char (HORIZONTAL_LINE) << char (INTERSECTION);
          }
               cout << "\b" << char (VERTICAL_WITH_LEFT_TURN) << "\n";
          }
          else {
               cout << "\b" << char (LEFT_LOWER_CORNER);
               for (int r=0; r<ROW; r++) {
                    cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_UP_LINE);
               }
          }
     }
     cout << "\b" << char (RIGHT_LOWER_CORNER) << "\n";
}
 
/****************************************************************************************/
/****************************************************************************************/
 
 
#define MIN_COL  2    //minimum size allowed for number of columns
#define MIN_ROW 2    //minimum size allowed for number of rows
#define MIN_DEPTH 2 //minimum size allowed for the depth
#define MAX_COL 12    //maximum size allowed for number of columns
#define MAX_ROW 12    //maximum size allowed for number of rows
#define MAX_DEPTH 12//maximum size allowed for the depth
#define RROW 11;
#define RCOL 11;
 
class GridActive:Dynamic3DArray {
 
private:
     int x;
     int y;
     int z;
 
public:
     GridActive ();
     GridActive ( int R, int C, int D);
     GridActive (const GridActive & grid);
     ~GridActive ();
 
//Accessors
     bool goNorth ();
     bool goSouth ();
     bool goWest ();
     bool goEast ();
     bool goUp ();
     bool goDown ();
     int getRow ();
     int getCol ();
     int getDepth ();
     int getX ();
     int getY ();
     int getZ ();
 
//Mutators
     void upsize ();
     void downsize ();
     void setActive ();
     void printDimentions (int x, int y, int z);
     void print (int dep);
 
};
 
GridActive::GridActive ():Dynamic3DArray () {
     x=0;
     y=0;
     z=0;
}
 
GridActive::GridActive (int R, int C, int D):Dynamic3DArray (R, C, D) {
     x=1;
     y=1;
     z=1;
}
 
GridActive::~GridActive () {
 
}
 
GridActive::GridActive (const GridActive & grid):Dynamic3DArray(grid) {
 
}
 
GridActive& GridActive::operator= (const GridActive & grid) {
     destroy ();
     this->x = grid.x;
     this->y = grid.y;
     this->z = grid.z;
     this->ROW = grid.ROW;
     this->COL = grid.COL;
     this->DEPTH = grid.DEPTH;
     create ();
     for (int r=0; r<ROW; r++) {
          for (int c=0;, c<COL; c++) {
               for (int d=0; d<DEPTH; d++)
               array[r][c][d]=grid.array[r][c][d];
          }
     }
     return *this;
}
 
bool GridActive::goNorth () {
     for (y == 1) return false;
     y--;
     return true;
}
 
bool GridActive::goSouth () {
     if (y == COL) return false;
     y++;
     return true;
}
 
bool GridActive::goDown () {
     if (z == 1) return false;
     z--;
     return true;
}
 
bool GridActive::goUp () {
     if (z == DEPTH) return false;
     z++;
     return true;
}
 
bool GridActive::goEast () {
     if (x == ROW) return false;
     x++;
     return true;
}
 
bool GridActive::goWest () {
     if (x == 1) return false;
     x--;
     return true;
}
 
int GridActive::getROW () {
     return ROW;
}
 
int GridActive::getCol () {
     return COl;
}
 
int GridActive::getDEPTH () {
     return DEPTH;
}
 
void GridActive::print (int dep) {
     Dynamic3DArray::print (dep)
}
 
int GridActive::getX () {
     return x;
}
 
int GridActive::getY () {
     return y;
}
 
int GridActive::getZ () {
     return z;
}
 
void GridActive::setActive (int x, int y, int z) {
     Dynamic3DArray::setActive (x, y, z);
}
 
void GridActive::printDimentions (int x, int y, int z) {
     Dynamic3DArray::printDimentions (x, y, z);
}
 
void GridActive::upsize() {
     if ((ROW< MAX_ROW-2) && (COL<MAX_COL-2) && (DEPTH< MAX_DEPTH-2)) {
          resize (this->ROW+2, this->COL+2, this->DEPTH+2);
          x++;
          y++;
          z++;
     }
}
 
void GridActive::downsize () {
     if (ROW>MIN_ROW && COL>MIN_COL && DEPTH>MIN_DEPTH &&
     this->x != this->y !=1 && this->z !=1 &&
     this->x != this->ROW && this->y != this->COL && this->z !=DEPTH) {
          resize (this->ROW-2, this->COL-2, this->DEPTH-2);
          x--;
          y--;
          z--;
     }
}
 
 
 
 
 
void printEnd() {
     system ("cls");
     cout << "XXXXXXXXXXX_XX_____XX_____XXX_____XXXX______XX_XXX____XXX______XXX______XXX____XXXXX_____XXX_____XXX_______" << endl;
     cout << "XXXXXXXXXXX_XX_____XX____XXXXX____XXXXX_____XX_XXX___XXX_______XXX____XXX____XXX___XXX___XXX_____XXX_______" << endl;
     cout << "_____XX_____XX_____XX___XXX_XXX___XX_XXX____XX_XXX__XXX________XXX__XXX____XXX______XXX__XXX_____XXX_______" << endl;
     cout << "_____XX_____XXXXXXXXX__XXX___XXX__XX__XXX___XX_XXXXXXX_________XXXXX_____XXX_________XXX_XXX_____XXX_______" << endl;
     cout << "_____XX_____XXXXXXXXX__XXXXXXXXX__XX___XXX__XX_XXXXXXX_________XXXX______XXX_________XXX_XXX_____XXX_______" << endl;
     cout << "_____XX_____XX_____XX_XXXXXXXXXXX_XX____XXX_XX_XXX__XXX________XXX_________XXX_____XXX___XXX_____XXX_______" << endl;
     cout << "_____XX_____XX_____XX_XXX_____XXX_XX_____XXXXX_XXX___XXX_______XXX__________XXX___XXX_____XXX___XXX________" << endl;
     cout << "_____XX_____XX_____XX_XXX_____XXX_XX______XXXX_XXX____XXX______XXX____________XXXXX_________XXXXXX_________" << endl;
     cout << "___________________________________________________________________________________________________________" << endl:
     cout << "XXXXXXXXX____XXXXX______XXXXXXX_______XXXXXXX____XX__________X_____XX_____XXX_XX_XXX_______XX______XXXXXX__" << endl;
     cout << "XXXXXXXXX__XXX___XXX____XXXXXXXX______XX___XXXX__XX_________XXX____XX___XXX___XX_XXXX______XX____XXXX___XX_" << endl;
     cout << "XX________XXX_____XXX___XX____XXX_____XX______XX_XX________XXXXX___XX_XXX_____XX_XX_XX_____XX__XXXX________" << endl;
     cout << "XXXXX___XXX_________XXX_XX   XXX______XX____XXX__XX_______XX__XXX__XXXX_______XX_XX__XX____XX_XX___________" << endl;
     cout << "XXXXX___XXX_________XXX_XXXXXXX_______XXXXXX_____XX_______XXXXXXX__XXX________XX_XX___XX___XX_XX______XXXXX" << endl;
     cout << "XX________XXX_____XXX___XX__XXX_______XX_________XX______XXXXXXXXX_XXX________XX_XX____XX__XX__XXXX_____XXX" << endl;
     cout << "XX_________XXX___XXX____XX___XXX______XX_________XXXXXXX_XX____XXX_XXX________XX_XX_____XXXXX____XXXXXXXXX_" << endl;
     cout << "XX__________XXXXX_______XX____XXX_____XX_________XXXXXXX_XX____XXX_XXX________XX_XX______XXXX______XXXXX___" << endl;
}
 
 
void main () {
     char keyPressed;
     bool quit = false;
     int dX;
     int dY;
     int dZ;
     do {
          system("cls");
          cout <<endl;
          cout <<endl;
          cout <<"xxxx___xxxx__xx__xxx____xxx__xxxxxx___xxxxxx___xxx___________xxx__xxxxxx__xxxxxx__xxxxx_____xxxxxx__xxxxxx__" << endl;
          cout <<"xxxx___xxxx__xx__xxxx___xxx__xxxxxx__xxxxxxxx__xxx___________xxx__xxxxxx__xxxxxx__xxxxxxx___xxxxxx__xxxxxxx_"<< endl;
          cout <<"xxxxx_xxxxx__xx__xxxx___xxx__xx______xxx__xxx__xxx___________xxx__xx______xx______xx___xxx__xx______xx___xx_"<< endl;
          cout <<"xxx_xxx_xxx__xx__xxxxx__xxx__xx______xxx________xxx_________xxx___xx______xx______xx___xxx__xx______xx___xx_"<< endl;
          cout <<"xxx_xxx_xxx__xx__xxx_xx_xxx__xxxxx____xxx_______xxx____x____xxx___xxxxx___xxxxx___xxxxxxx___xxxxx___xxxxxx__"<< endl;
          cout <<"xxx__x__xxx__xx__xxx__xxxxx__xxxxx______xxx______xxx___x___xxx____xxxxx___xxxxx___xxx_______xxxxx___xxxx____"<< endl;
          cout <<"xxx_____xxx__xx__xxx__xxxxx__xx___________xxx____xxx__xxx__xxx____xx______xx______xx________xx______xx_xx___"<< endl;
          cout <<"xxx_____xxx__xx__xxx___xxxx__xx______xxx__xxx_____xxxx___xxxx_____xx______xx______xx________xx______xx__xx__"<< endl;
          cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx__xxxxxxxx_____xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx__"<< endl;
          cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx___xxxxxx______xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx__"<< endl;
     cout << endl << endl << endl;
     system("pause");
     int main() {
          HANDLE  hConsole;
          int k;
          hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
           for(k = 1; k < 2; k++) {
               SetConsoleTextAttribute(hConsole, 26);
               cout <<"You may use the ESC button to quit MINESWEEPER anytime you wish" << endl;
               cout <<"The arrow buttons on your keyboard will be used to move your player around" << endl;
               cout <<"The buttons < and > will be used to go up and down levels" << endl;
               cout <<"The buttons = or - will be used to increse or decrease the size of your game" << endl;
               system("pause");
               cout << "Enter the number of rows you would like to have" << endl;
               cin >> dX;
               while (dX > MAX_ROW) {
                    cout << "Please re-enter the number of rows you would like that is less than your previous entry" << endl;
                    cin >> dX;
               }
               while (dX < MIN_ROW) {
                    cout << "Please re-enter the number of rows you would like that is greater than your previous entry" << endl;
                    cin << dX;
               }
               cout << "Enter the number of columns you would like to have" << endl;
               cin >> dY;
               while (dY > MAX_COL) {
                    cout << "Please re-enter the number of columns you would like that is less than your previous entry" << endl;
                    cin >> dY;
               }
               while (dY < MIN_COL) {
                    cout << "Please re-enter the number of columns you would like that is greater than your previous entry" << endl;
                    cin >> dY;
               }
               cout << "Enter the depth you would like to have" << endl;
               cin >> dZ;
               while (dZ > MAX_DEPTH) {
                    cout << "Please re-enter the depth you would like that is less than your previous entry" << endl;
                    cin >> dZ;
               }
               while (dZ < MIN_DEPTH) {
                    cout << "Please re-enter the depth you would like that is greater than your previous entry" << endl;
                    cin >> dZ;
               }
 
               GridActive myGridActive (dX, dY, dZ);
               do{
               myGridActive.setActive ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ());
               myGridActive.print (myGridActive.getZ());
               myGridActive.printDimensions ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ() );
               myGridActive.printDimensions ( myGridActive.getROW(), myGridActive.getCOL(), myGridActive.getDEPTH() );
               keyPressed = toascii ( getch() );
               switch (keyPressed) {
                    case 27 : quit = true; break;
                    case 44 : myGridActive.goDown (); break;
                    case 46 : myGridActive.goUp (); break;
                    case 61 : myGridActive.upsize (); break;
                    case 99 : system ("cls"); break;
                    case 45 : myGridActive.downsize (); break;
                    case 96 : {
                         keyPressed = toascii (getch() );
                         switch (keyPressed) {
                              case 72 : myGridActive.goNorth (); break;
                              case 80 : myGridActive.goSouth (); break;
                              case 75 : myGridActive.goWest (); break;
                              case 77 : myGridActive.goEast (); break;
                              default: break;
                         }
                    default: break:
                    }
               }
          }
          while (!quit);
          cout << "\n Would you like to start over? Press any key \n  Would you like to quit? Press N ";
          keyPressed = getch ();
          quit = false;
          if (( keyPressed == 'N' ) || (keyPressed == 'n' ))
          quit = true;
     }
}
 
     cin.get(); // wait
     return 0;
}
     while (!quit);
     printEnd();
}

Sorry, doesn't compile:

//Mutators
     void setActive (); // Gets console ready to draw minesweeper grid
     char draw(); // Draws the grid for minesweeper
Room *** array;

What are your trying to do here? Create a pointer-to-etc to a room called array? Or are you trying to make an array of pointers-to-etc?

And there's a few typo's in here, marked in red:

for (int r=0; r<Row; r++)   //row is undeclared
void Dynamic3DArray:: setActive (intx, int y, int z) //a space 
for (int r=0; r<ROW; r++) { //line 214 redefined

There are also some general error's with your classes, but since this is not my specialty (i like c not ++ :) ) maybe someone else could inform you.

I don't have enough time to find them all (after this there are still 62..). I strongly suggest that you download a compiler, it's makes debugging a whole lot easier. Which compilers have you allready tried?

thereason why i didnt wanna post it is cause i dont want no one stealing my game code

No comment. :rolleyes:

Inside the definition of Room:

char draw; // Draws the grid for minesweeper

You later go on to define Room::draw(). Perhaps you forgot parentheses in the class definition?

Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}

Your code is trying to access private members from a foreign class. If you need to, create a function in Room that reads and returns the values of visited and active . Also, why are you using this to modify variables inside its local scope? To modify Room::visited inside Room::Room(), simply use something like:

visited = node.isVisited(); // used isVisited() because visited is private

Little typo:

class Dynamic3DArray {
 
protected:
         int ROW;
     int COL;
     int DEPTH;
     Room *** array;
 

public;

Another error:

void Dynamic3DArray::destroy () {
     for (int r=0; r<Row; r++) { // previously declared as int ROW

A large number of errors that follow are because of the way you declared array in Dynamic3DArray. Niek explained this, so refer to his post on how to fix this.

After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h .

Hope this helps

I put the pointer there to make an array of pointers. What is the correct way to do it?


Inside the definition of Room:

char draw; // Draws the grid for minesweeper

You later go on to define Room::draw(). Perhaps you forgot parentheses in the class definition?

Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}

Your code is trying to access private members from a foreign class. If you need to, create a function in Room that reads and returns the values of visited and active . Also, why are you using this to modify variables inside its local scope? To modify Room::visited inside Room::Room(), simply use something like:

visited = node.isVisited(); // used isVisited() because visited is private

Little typo:

class Dynamic3DArray {
 
protected:
         int ROW;
     int COL;
     int DEPTH;
     Room *** array;
 
 
public;

Another error:

void Dynamic3DArray::destroy () {
     for (int r=0; r<Row; r++) { // previously declared as int ROW

A large number of errors that follow are because of the way you declared array in Dynamic3DArray. Niek explained this, so refer to his post on how to fix this.

After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h .

Hope this helps

Member Avatar for iamthwee

After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h.

My guess is he has declared windows.h for the colour bit? And conio.h to catch input without needing the user to hit return.

Of course that throws out the chance of his code being portable and all. :lol:

I put the pointer there to make an array of pointers. What is the correct way to do it?

I would think you would only need to declare it as Room **array; . I've kind of forgotten what exactly you needed this array for, because you could just declare the number of elements immeditately, or if it has to be dynamic, you could use vectors/linked list.

I did that and it has seemed to fix those errors, thank you. But there one error i getting now like 15 times in my program. this is the error

error C2659: '=' : overloaded function as left operand

Thats for this line this->visited= false; .
That little piece of code is within the Room Class part where all of that same error is. And it is all the this-> (active or visited) = (something) all have that same error. Its lines 73, 74, 79, 80, etc.

I would think you would only need to declare it as Room **array; . I've kind of forgotten what exactly you needed this array for, because you could just declare the number of elements immeditately, or if it has to be dynamic, you could use vectors/linked list.

I did that and it has seemed to fix those errors, thank you. But there one error i getting now like 15 times in my program. this is the error

error C2659: '=' : overloaded function as left operand

Thats for this line this->visited= false; .
That little piece of code is within the Room Class part where all of that same error is. And it is all the this-> (active or visited) = (something) all have that same error. Its lines 73, 74, 79, 80, etc.

There's no need to use this-> . Since these functions are inside Room , they are in scope. To access variables that are in the same object as the function, you can simply use:

visited=false;

I see no reason why you continue to prefix these variables with this-> . Remove all references of this-> in front of local variables, and the errors should go away.

Hope this helps

The error still comes up the same even when I take out the "this->" :sad:


There's no need to use this-> . Since these functions are inside Room , they are in scope. To access variables that are in the same object as the function, you can simply use:

visited=false;

I see no reason why you continue to prefix these variables with this-> . Remove all references of this-> in front of local variables, and the errors should go away.

Hope this helps

The error still comes up the same even when I take out the "this->" :sad:

You're totally using the wrong syntax when trying to overload the = operator in Room :

// prototype in class
Room &operator= (const Room& node); // Operator

// main function
Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}

First, why are you returning a pointer? You simply need to pass the object back, not a pointer. In the implementation, you aren't referencing the class object! Here is how an overloaded operator function should look like:

MyClass MyClass::operator =(MyClass &argument1) {
    // assign/do math here...

    return argument1;
}

And it's prototype:

class MyClass {
   public:
   // ...
   MyClass operator =(MyClass &argument1);
};

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.