此功能与主功能位于同一文件时有效。当我将其携带到另一个文件时,它不起作用。这是我携带后的代码:
channel.h
class Channel {
template <typename AnyType>
static void addNoise(AnyType const first, AnyType const last, double
stdDev);
};
channel.cc
template <typename AnyType>
void Channel::addNoise(AnyType const first, AnyType const last, double
stdDev){
std::default_random_engine generator(time(0));
std::normal_distribution<double> normDistribution(0, stdDev);
AnyType pointer = first;
while (pointer != last){
*pointer = *pointer + normDistribution(generator);
pointer++;
}
}
然后从主函数中调用它:
Channel::addNoise(receivedSignal.begin(), receivedSignal.end(), standardDeviation);
编译器出现此错误:未定义引用...(函数句柄的前两个参数为:normal_iterator double *)。