| tmorlan (7) | |||||
|
Hi, I am working on a project for school, and I have run into a problem. I am trying to create a dynamically allocated array of Class objects, which is determined through file reading, and I can't get it to work. The Boss and Enemy classes inherit from the Location class. Also, in this particular class file, my compiler is underlining = and << . I used #include <iostream> and using namespace std; so there must be some other problem.If you can fix any errors I would really appreciate it. Thanks. header file
.cpp file
oh, and the file i'm reading from looks like this currently. 5 5 L L L E L L L E L L L L L L L L E L E L L L L L B | |||||
|
Last edited on
|
|||||
| tmorlan (7) | |
| I forgot to mention that this project is due at midnight tonight, so time is really an issue here. | |
|
|
|
| firedraco (5494) | |
| What are the errors you are getting? | |
|
|
|
| tmorlan (7) | |
|
I am getting C2679, C2146, C2065, and C2061. And they are happening on lines 25-29. | |
|
|
|
| tmorlan (7) | |||
To make the question more specific... if i initialize an 2d array of pointers. like this Location **arr2;And I try to define it like this.
What am I doing wrong? | |||
|
|
|||
| LowestOne (895) | |
|
If I was your teacher I would be pissed that your living things are locations. How do they move? Living things have locations. Anyway, here is how to create a 2d array: http://www.cplusplus.com/forum/general/9508/ Read the whole thread, "Tristanm is correct". | |
|
Last edited on
|
|
| tmorlan (7) | |||
|
Thanks a lot for the help, it fixed most of my problems. I just have one last question. In this function, I have allocated the space for the 2d array and defined each pointer, but I want to go through the array and change what default object some of the pointers are pointing at based on information from a text file. I am trying to convert a Location pointer to a Enemy, Boss, or Riddles pointer (Enemy, Boss, and Riddle inherit from Location) here is my modified function
the part that doesn't work is on lines 28-33 | |||
|
Last edited on
|
|||