chaichao27 2015-03-31 13:27 采纳率: 0%
浏览 4134
已结题

VS2013,C++,error LNK2019和LNK1120

output:1>------ Build started: Project: chapter5 使用序列式容器并分析字符串, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol "class std::vector,class std::allocator >,class std::allocator,class std::allocator > > > __cdecl split(class std::basic_string,class std::allocator > &)" (?split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) referenced in function _main
1>C:\Users\cc\Desktop\Accelerated C++\exercise\chapter5 使用序列式容器并分析字符串\Debug\chapter5 使用序列式容器并分析字符串.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
split.cpp:

//使用索引实现的split函数
#include
#include
#include
#include

using namespace std;

vector split(const string &s)
{
vector ret;
typedef string::size_type string_size;
string_size i = 0;

while (i != s.size())
{
    while (i != s.size() && isspace(s[i]))
        ++i;

    string_size j = i;
    while (j != s.size() && !isspace(s[j]))
        ++j;

    if (i != j)
    {
        ret.push_back(s.substr(i, j - i));
        i = j;
    }
}
return ret;

}

split.h:

#ifndef GUARD_split_h
#define GUARD_split_h

#include
#include
std::vectorstd::string split(std::string &s);

#endif

Source.cpp

#include "split.h"
#include
#include
#include
#include

using namespace std;

int main()
{
string s;

while (getline(cin, s))
{
    vector<string> v = split(s);

    for (vector<string>::size_type i = 0; i != v.size(); ++i)
        cout << v[i] << endl;
}
return 0;

}

我用的是空项目建立的,搞不懂是为什么出问题了,新手啊

  • 写回答

3条回答 默认 最新

  • oyljerry 2015-04-01 03:13
    关注

    cpp中实现的时候

     vector split(string &s)
     {
     }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器