我在這裏丟失了什麼嗎?或者有沒有原因,這是不允許的?使用模板基類作爲基類參數的類
// the class declaration
class MapImage : public MapEntity, public Vector2D {};
// the variable declaration
std::vector<MapImage> healthpacks;
// the function
void DrawItems(SDL_Surface *dest, std::vector<Vector2D> &items, SDL_Surface *image);
// the implementation
DrawItems(dest, healthpacks, healthpack_image);
因爲healthpacks是MapImage類的一個std ::向量,MapImage有基類的Vector2D,不應該「的std ::矢量healthpacks」與兼容「的std ::矢量&項目」,因爲它們有相同的基類?
是的。你會得到什麼編譯錯誤? – 2011-01-21 05:07:41
使用<或反引號,這樣您的向量不會在問題文本中被誤解(與變得隱藏)。 –
2011-01-21 05:34:51