Well, here's my end goal. If someone has a better way to go about it, let me know.
I'm writing a 2D DirectX game in C++ and am drawing sprites to the screen. I have all the sprites wrapped in a class called "spriteInfo" and they're being stuffed into a std::list<spriteInfo>, which throws everything on the screen using the spriteInfo structs.
The game is 1-4 players, so I have another 1-4 sprites (the character(s)) that I want the user(s) to control. These sprites are wrapped in a class called "character", which inherits from "spriteInfo". They're being added to the spriteInfo list, so they're drawn to the screen like everything else. I need to be able to quickly access the data members of each character so I can update their positions in the world.
So here's what I'm doing... I've got an array of iterator pointers (std::list<character>::iterator*), that theoretically should be pointing to the location of the iterator in the list where the character sprite(s) are being stored. However, I'm getting a compiler error when I try this. It looks like it's related to inheritance. Here's what the code looks like:
class spriteInfo {
public:
float x, y, elevation, scale;
float width, height;
float distToCamera;
IDirect3DTexture9* texture;
};
class character : public spriteInfo {
public:
float angle;
float angleAccel;
float speed;
};
std::list<spriteInfo> spriteList;
characters = new std::list<character>::iterator*[cameraCount];
for (int i=0; i<cameraCount; i++) {
character c;
// character data populated here
spriteList.push_front(c);
characters = &spriteList.begin();
}
Here is the error I am getting:
Quote:error C2440: '=' : cannot convert from 'std::list<_Ty>::iterator *__w64 ' to 'std::list<_Ty>::iterator *'
with
[
_Ty=spriteInfo
]
and
[
_Ty=character
]
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
How would I go about getting this fixed?