我正在尝试编写本书中第 7 章中的第二个练习。我创建了一个包含外部参照函数的头文件:
#pragma once
#include <map>
#include <string>
#include <vector>
#include "split.h"
std::map<std::string, std::vector<int> > xref(std::istream&, std::vector<std::string> find_words(const std::string&) = split);
然后我写了.cpp文件:
#include "xref.h"
using namespace std;
map<string, vector<int> > xref(istream& in, vector<string> find_words(const string&) = split) {
...
}
我无法编译代码,它说参数 1 不匹配。怎么了?
最佳答案
错误消息准确说明了错误所在:您应该只在函数声明中指定默认参数值,而您在函数定义中又做了一次。错误是指函数的最后一个参数。
关于c++ - 加速的 C++ 头文件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45782016/