C++Primer书中的一个函数
本帖最后由 horsedong 于 2013-03-27 17:58:44 编辑 头文件io_preamble.h为
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <iomanip>
using namespace std;
main函数为
#include "io_preamble.h"
#include <stdexcept>
// prototypical main function that takes a file name to open
int main(int argc, char **argv)
{
if (argc < 2)
throw range_error("No file name given");
ifstream in;
open_file(in, argv[1]);
string word;
while (in >> word)
cout << word << endl;
return 0;
}
用visual studio 2012运行时提示“ error LNK2019: 无法解析的外部符号 "class std::basic_ifstream<char,struct std::char_traits<char> > & __cdecl open_file(class std::basic_ifstream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?open_file@@YAAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z),该符号在函数 _main 中被引用”
求各位大神指导一下。刚学习C++ c++ 无法解析的外部符号? C++Primer
[解决办法]
我运行了一下,没有这个错误啊,你包含open_file了吗?open_file 是作者自己写的那个函数
C++Primer书中的一个函数,该如何处理
C++Primer书中的一个函数本帖最后由 horsedong 于 2013-03-27 17:58:44 编辑头文件io_preamble.h为#includ
