将2D向量传递给函数时的未定义引用

时间:2018-12-01 20:47:26

标签: c++ vector stl

我正在编写一个c ++程序,我想将2D矢量传递给函数进行修改,但是当我尝试调用此函数时,我得到了未定义的引用。现在,我知道此错误意味着什么。我不明白的是进一步的事情,因为我的编译器试图用3D向量调用函数?我的推理哪里出错了?

函数的.h文件声明

static void mutate(unsigned mutationCoeficcient, 
                     bool displacementMutation, 
                     std::vector<std::vector<unsigned>>& newGeneration);

.cpp定义

void mutate(unsigned mutationCoeficcient, bool displacementMutation, 
            std::vector<std::vector<unsigned>>& newGeneration){
/.../
//newGeneration is changed here
/.../
}

呼叫(来自班级内部)

std::vector<std::vector<unsigned> > newGeneration;
/.../
//elements are added to newGeneration here
/.../
Graph::mutate(mutationCoeficcient, displacementMutation, newGeneration);

和错误,似乎调用了不同的功能

Graph.cpp|| undefined reference to `Graph::mutate(unsigned int, bool, std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >&)'|

0 个答案:

没有答案