为什么我不能重载这个构造函数?

时间:2015-02-26 11:23:10

标签: c++

我正在编写一个类来帮助模型。 有一段代码,这一段(来自.cpp文件):

Model GameModels::getModel(std::string& gameModelName){
    return GameModelList.at(gameModelName);
}

这引发了这个错误:

  

Models.h:44:9:错误:'模型::模型   Models :: GameModels :: getModel(std :: string&)'不能超载
  模型getModel(std :: string& gameModelName);            ^ Models.h:40:9:错误:使用'Models :: Model Models :: GameModels :: getModel(std :: string&)'模型   getModel(std :: string& gameModelName);

关于g ++。这是我的模型定义:

struct Triangle{
    VertexFormat x;
    VertexFormat y;
    VertexFormat z;
};

struct Model{
    unsigned int vao;
    std::vector<unsigned int> vbos;
    std::vector<Triangle> geometry;
    std::string shaderFilepath;
    Model(){}
};

1 个答案:

答案 0 :(得分:1)

根据错误消息(与发布的代码无关),在Model.h的第40和44行声明相同的函数两次。

相关问题