在类中使用 ifstream

发布于 2024-12-08 21:40:38 字数 384 浏览 6 评论 0原文

在 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装迷糊 2024-12-15 21:40:38

试试这个:
无效读取(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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文