C++ C+中未定义的引用错误+;代码

C++ C+中未定义的引用错误+;代码,c++,compilation,C++,Compilation,您好,我在编译代码时遇到此错误: main.cpp:(.text.startup+0xfc): undefined reference to `CMyMath::melFilterBank(std::vector<double, std::allocator<double> >, int, int, int)' collect2: error: ld returned 1 exit status make: *** [bin/main.elf] Error 1 main

您好,我在编译代码时遇到此错误:

main.cpp:(.text.startup+0xfc): undefined reference to `CMyMath::melFilterBank(std::vector<double, std::allocator<double> >, int, int, int)'
collect2: error: ld returned 1 exit status
make: *** [bin/main.elf] Error 1
main.cpp:(.text.startup+0xfc):对“CMyMath::melFilterBank(std::vector,int,int,int)”的未定义引用
collect2:错误:ld返回了1个退出状态
make:**[bin/main.elf]错误1
我的.h文件:

#ifndef _MYMATH_H_
#define _MYMATH_H_
#define _USE_MATH_DEFINES
#include <vector>
#include <stdio.h>
#include <cmath>
#include <stdint.h>
#include <complex> 
class CMyMath
{
    public:
        CMyMath();  
        ~CMyMath();
        std::vector<double> melFilterBank(std::vector<double> signal, int frequency, int band_num, int coef_num);
};
#endif
\ifndef\u MYMATH\u H_
#定义我的数学_
#定义使用数学定义
#包括
#包括
#包括
#包括
#包括
CMyMath类
{
公众:
CMyMath();
~CMyMath();
标准::矢量滤波器组(标准::矢量信号,整数频率,整数频带数,整数系数);
};
#恩迪夫
my.cpp文件:

#include "MyMath.h"    
CMyMath::CMyMath()
{
    printf("constructor called\n");
}   
CMyMath::~CMyMath()
{
    printf("destructor called\n");
}
std::vector<double> melFilterBank(std::vector<double> ourSignal, int frequency, int bandNum, int coefNum)
{
    std::vector<double> output; //ck in matlab code
    /*
    DO SOME STUFF
    */
    return output;
}
#包括“MyMath.h”
CMyMath::CMyMath()
{
printf(“调用的构造函数”);
}   
CMyMath::~CMyMath()
{
printf(“称为析构函数的\n”);
}
标准::矢量滤波器组(标准::矢量信号、整数频率、整数带宽、整数系数)
{
std::vector output;//matlab代码中的ck
/*
做点什么
*/
返回输出;
}
主要内容:

#包括
#包括
#包括
#包括“MyMath.h”
int main()
{
CMyMath a类;
std::向量mel{0.0000001,0.0000005,0.0000004,0.0000005};
a、 melFilterBank(mel,8000,6,5);
返回0;
}
你认为哪里应该出错?我是C++新手,我真的不知道怎么回事。你有什么建议

定义(在
.cpp
文件中)需要指定您定义的是成员函数,而不是单独的非成员函数:

std::vector<double> CMyMath::melFilterBank(std::vector<double> ourSignal, int frequency, int bandNum, int coefNum)
                    ^^^^^^^^^
std::vector CMyMath::melFilterBank(std::vector ourSignal,int frequency,int bandNum,int coefNum)
^^^^^^^^^
std::vector CMyMath::melFilterBank(std::vector ourSignal,int frequency,int bandNum,int coefNum)

定义时的成员函数需要以类名作为前缀。

std::vector melFilterBank
缺少类限定符
CMyMath::
现在我看到了,谢谢@WhozCraig
std::vector<double> CMyMath::melFilterBank(std::vector<double> ourSignal, int frequency, int bandNum, int coefNum)
                    ^^^^^^^^^
std::vector<double> CMyMath :: melFilterBank(std::vector<double> ourSignal, int frequency, int bandNum, int coefNum)