在类中使用 ifstream
在 .h 文件和实现文件中使用 ifstream 时出现以下错误,我在主文件、方法定义和 .h 文件中都有 fstream 包含文件。
'no void Rational::read(std::ifstream&)' member function declared in class variable or field `read' declared void
这是有理类 .h 文件中的方法声明。
void read(ifstream &);
以及方法定义。
void Rational::read(ifstream &ratfile)
I'm getting the following errors when using ifstream in a .h file and the implementation file,,I have the the fstream include files in both the main ,the method definitions and .h file.
'no void Rational::read(std::ifstream&)' member function declared in class variable or field `read' declared void
Heres the method declaration in the rational class .h file.
void read(ifstream &);
And the method definition.
void Rational::read(ifstream &ratfile)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
无效读取(std::ifstream &); // 在头文件中
void Rational::read(std::ifstream &ratfile) // 在 cpp 文件中
Try this:
void read(std::ifstream &); // in the header file
void Rational::read(std::ifstream &ratfile) // in the cpp file