“未找到搜索标识符”
我有一个名为 main: 的程序
#include<iostream>
#include<fstream>
using namespace std;
#include"other.h"
int main()
{
//do stuff
}
,然后是 other.h:
char* load_data(int begin_point,int num_characters)
{
seekg(begin_point);
char* return_val=new char[num_characters+1];
mapdata.getline(return_val,num_characters);
return return_val;
}
,我收到错误:
“seekg”:未找到标识符
为什么会出现此错误以及如何修复它?
I have a program called main:
#include<iostream>
#include<fstream>
using namespace std;
#include"other.h"
int main()
{
//do stuff
}
and then other.h:
char* load_data(int begin_point,int num_characters)
{
seekg(begin_point);
char* return_val=new char[num_characters+1];
mapdata.getline(return_val,num_characters);
return return_val;
}
and I get the error:
'seekg': identifier not found
why do I get this error and how do I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
eekg 是 fstream(在 istream 中声明)类中的一个方法。
你还没有实例化任何。
以此为例
源: http://www.cplusplus.com/reference/ iostream/istream/seekg/
因此,您应该
考虑 ParoXon 在您的问题中评论的内容。
您应该创建一个包含函数的 load_data 实现的 other.cpp 文件。
文件 other.h 应包含函数的 load_data 声明。 在该文件(other.h)中,您应该包含其中声明的函数正常工作所需的所有文件。 并且不要忘记保护自己免受多重包含的影响!
文件 other.h
文件 other.cpp
seekg is a method from the fstream (declared in istream) class.
You haven't instantiated any.
Take this as an example
source: http://www.cplusplus.com/reference/iostream/istream/seekg/
So, you should
Take into account what ParoXon commented in your question.
You should create a file other.cpp containing function's load_data implementation.
File other.h should contain function's load_data declaration. In that file (other.h) you should include all files neccesary for functions declared there to work. And dont forget to protect yourself against multiple includes !
File other.h
File other.cpp