C++ primer中,"单词转换"map对象源码问题
2014-02-19 16:53
239 查看
单独编译word_transform.cc文件的时候报错:
原因:word_transform.cc这个文件的源码中,只在最上面声明了open_file()函数。但是没有在后面实现该函数,所以,会报open_file()未定义的错误。
注:通过makefile文件将gnu_files文件夹下所有源码一起编译word_transform.cc是可以通过的,所以,说明open_file这个函数是在某个文件里面实现了。只是本来找人半天没找到在哪里。如果有人找到可以tell me,tks
word_transform.cc:(.text+0x133):对‘open_file(std::basic_ifstream<char, std::char_traits<char> >&, std::string const&)’未定义的引用 word_transform.cc:(.text+0x533):对‘open_file(std::basic_ifstream<char, std::char_traits<char> >&, std::string const&)’未定义的引用 word_transform.cc:(.text+0x703):对‘open_file(std::basic_ifstream<char, std::char_traits<char> >&, std::string const&)’未定义的引用 collect2: 错误: ld 返回 1
原因:word_transform.cc这个文件的源码中,只在最上面声明了open_file()函数。但是没有在后面实现该函数,所以,会报open_file()未定义的错误。
ifstream& open_file(ifstream&, const string&); 其源码如下: ifstream& open_file(ifstream &in, const string &file) { in.close(); // close in case it was already open in.clear(); // clear any existing errors // if the open fails, the stream will be in an invalid state in.open(file.c_str()); // open the file we were given return in; // condition state is good if open succeeded }在word_transform.cc文件最下面加上open_file()函数源码就可以正常运行了。
注:通过makefile文件将gnu_files文件夹下所有源码一起编译word_transform.cc是可以通过的,所以,说明open_file这个函数是在某个文件里面实现了。只是本来找人半天没找到在哪里。如果有人找到可以tell me,tks
相关文章推荐
- C++ primer ————————————“单词转换" map 对象
- C++ 10.3.9 "单词转换"map对象
- C++ Primer 第十章 10.3.9 “单词转换”map对象
- C++ primer 单词转换 map对象
- C++ primer 单词转换(使用map对象)
- "automation服务器不能创建对象”的问题的解决方案总结大全
- 未将对象引用设置到对象的实例"的问题
- c语言处理fopen(path,"wb")的路径转换问题
- java程序员跟C++程序员讨论"格林威治标准时间”的转换问题的真实故事之感悟
- String s=new String("xyz");创建几个String对象的问题
- 关于asp.net 下发送邮件 未能访问"CDO.Message"对象 问题(1)
- String s = "a" + "b" + "c" + "d" + "e"对象问题
- " LINK :fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏"问题的最终解决办法
- 解决list转换json出现的各类问题 object转换为Map对象
- 使用eval转换json对象时为什么外边还要加括号eval("("+data+")");
- String s=new String("xyz");创建几个String对象的问题
- 关于String a=new String("a")创建几个对象问题的正确答案
- 【C++ Primer】【练习题】【3.14】将vector<string>对象各元素中的小写字母转换成大写字母
- "LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏"的问题的解决
- 出现"未将对象引用设置到对象的实例“问题的总结