c++ - 加速的 C++ 头文件不起作用

标签 c++ dictionary parameters

我正在尝试编写本书中第 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/

相关文章:

linux - 如何从Linux中的自定义别名获取参数

c - 为什么我不能使用函数返回值作为参数?

c++ - 如何在最小化窗口后最大化它

python - 检查 ansible 上 Jinja2 模板中的字典中是否存在 key

dictionary - Elm:如何合并两个字典?

c# - 将字典转换为两个列表的最佳方法

C++11 `using` 关键字 : specialize template alias of template parameter

c++ - 由于对 callcc 的调用不明确,Boost 协程无法编译

c++ - 访问使用 pinned_allocator 分配的 host_vector 项(推力库)

php - 警告 : mysql_query() expects parameter 2 to be resource