using namespace std; ofstream be; char fnbuf[256]; sprintf(fnbuf" />
您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> C/C++ >> 子函数调用oftream的问题

子函数调用oftream的问题

来源:网络整理     时间:2016/8/31 23:09:27     关键词:

关于网友提出的“ 子函数调用oftream的问题”问题疑问,本网通过在网上对“ 子函数调用oftream的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 子函数调用oftream的问题
描述:

ofstream参数子函数

需要在子函数中实现数据输出
编译时出现错误:error C2061: 语法错误 : 标识符“ofstream”

// main函数
#include "stdafx.h"
#include 
using namespace std;
ofstream be;
char fnbuf[256];
sprintf(fnbuf,"out.txt");
out.open(fnbuf);
myfunc(be);
// 子函数声明
void myfunc(ofstream s)

该怎么解决?
解决方案1:

引用 3 楼 zizi7 的回复:
但这时它会出现函数重载的错误,编译还是error C2061:语法错误 : 标识符“ofstream”


// 声明
#include 
void myfunc(std::ofstream *);
// 定义
#include 
void myfunc(std::ofstream *s)
{}

以上介绍了“ 子函数调用oftream的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3689945.html

相关图片

相关文章