VC中使用了fstream,却总是报错,求大神指点

emolingzhu 2016-05-05 08:51:19
VC中想要使用 fstream ,但程序一运行总是报错,求大神指点该怎么解决

然后我从别人那儿得到一个程序,也是一样使用了fstream,那个程序在我电脑上跑就能编译,我完全复制那个程序,但还是不能编译,烫染后我看了看我的fstream和他的fstream内容不太一样。。。应该怎么改呢?我直接拷贝的话好像还是不行
这个infile是我从那个类向导中的成员变量中自定义自动生成的,类型fstream.
在Dlg.h中是这么定义的
protected:
// bool m_IsShow;
BOOL m_IsShow;
BOOL Flag;
CString str;
long int Num;
CTime TimerT;
fstream infile;
Dlg.h中头文件是
#pragma once

#include "Afxtempl.h "
#include "afxdlgs.h"
#include <fstream>
#include <iostream>
#include <time.h>

Dlg.cpp中头文件是

#include "stdafx.h"
#include "test15.h"
#include "test15Dlg.h"
#include "afxdialogex.h"
#include <fstream>
#include <iostream>

报错的内容是
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C2146: 语法错误: 缺少“;”(在标识符“infile”的前面)
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1> test15.cpp
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C2146: 语法错误: 缺少“;”(在标识符“infile”的前面)
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\users\administrator\desktop\test15\test15\test15dlg.h(53): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
...全文
144 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
emolingzhu 2016-05-06
  • 打赏
  • 举报
回复
果然很有用!
emolingzhu 2016-05-06
  • 打赏
  • 举报
回复
在dlg.h声明后加了行这个 :using namespace std;就没问题了!谢谢解答
emolingzhu 2016-05-06
  • 打赏
  • 举报
回复
这个应该怎么处理呢?能不能讲一下源程序,我不太懂
ForestDB 2016-05-05
  • 打赏
  • 举报
回复
namespace处理了没? 比如std:: 或者using之类的。

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧