TyrantKing
Programmer
I am trying to display a game board using ascii characters. My initial attempts were successful, but something strange has happened, and I don't know what to do.
I am storing information in a two-dimensional array of a user-defined object type. Within this object class is a character code that contains the ascii number value corresponding to the symbol I want to be displayed. I have overloaded the << operator to display the symbol simply by entering cout << objectVariable; I would run some nested for loops to set the appropriate values into the appropriate objects in the array, and display the array using nested for loops with the overloaded output operator. This seemed to work how I planned, however, when I tried to implement the next part of the program everything fell apart.
I needed different data to be stored in different objects, so I used public inheritence to create additional types of objects, and converted the array of objects into an array of pointers to objects. I adjusted the initialization and display loops to handle the pointers, but something has gone wrong with the display. I have not put any of the new objects into the array ( I am still using the original object types ), but three-quarters of the way through the display the ascii characters begin to break down. I have tried setting them up as unsigned chars (as most of the codes I need are around the 200 mark), and have tried using signed characters converting the high codes into their negative, signed equivalent. I have tried static casts and tried running the codes as integers and then casting them as characters during output, but to no avail.
I am at a complete loss, as it works most of the way through the display. The array is 27 x 43, and it works all the way up until [22][36]. At array index [22][37] in goes beserk, and randomly changes the ascii values.
Any feedback on what could be causing this would be greatly appreciated!
I am storing information in a two-dimensional array of a user-defined object type. Within this object class is a character code that contains the ascii number value corresponding to the symbol I want to be displayed. I have overloaded the << operator to display the symbol simply by entering cout << objectVariable; I would run some nested for loops to set the appropriate values into the appropriate objects in the array, and display the array using nested for loops with the overloaded output operator. This seemed to work how I planned, however, when I tried to implement the next part of the program everything fell apart.
I needed different data to be stored in different objects, so I used public inheritence to create additional types of objects, and converted the array of objects into an array of pointers to objects. I adjusted the initialization and display loops to handle the pointers, but something has gone wrong with the display. I have not put any of the new objects into the array ( I am still using the original object types ), but three-quarters of the way through the display the ascii characters begin to break down. I have tried setting them up as unsigned chars (as most of the codes I need are around the 200 mark), and have tried using signed characters converting the high codes into their negative, signed equivalent. I have tried static casts and tried running the codes as integers and then casting them as characters during output, but to no avail.
I am at a complete loss, as it works most of the way through the display. The array is 27 x 43, and it works all the way up until [22][36]. At array index [22][37] in goes beserk, and randomly changes the ascii values.
Any feedback on what could be causing this would be greatly appreciated!