我在这里丢失了什么吗?或者有没有原因,这是不允许的?使用模板基类作为基类参数的类
// 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