错误 C2039:“打开” : 不是 'std::basic_fstream 的成员
当我
void fileOpen(const char*
fname_){file_.Open(fname_,ios::in|ios::out|ios::ate|ios::binary);};
像这样调用函数 时 tempobj->fileOpen("LastID.dat");
它给了我错误
Error 23 error C2039: 'Open' : is not a member of 'std::basic_fstream<_Elem,_Traits>'
我该如何解决这个问题。这是我有这个功能的类。这是模板类
#ifndef FileHandlerh_h
#define FileHandlerh_h
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
template <class T>
class FileHandler
{
private:
fstream file_;
public:
FileHandler(){};
FileHandler(const char* fname_){fileOpen(fname_);};
void fileOpen(const char* fname_){file_.Open(fname_,ios::in|ios::out|ios::ate|ios::binary);};
void fileWrite(T);
void fileSeekWrite(T,int);
T fileRead(int);
int getNoOfRecords();
~FileHandler(){file_.close();};
};
帮我解决这个问题...!!
When i call
void fileOpen(const char*
fname_){file_.Open(fname_,ios::in|ios::out|ios::ate|ios::binary);};
Function like
tempobj->fileOpen("LastID.dat");
It gives me the error
Error 23 error C2039: 'Open' : is not a member of 'std::basic_fstream<_Elem,_Traits>'
How do i resolve this. This is the class I have this function. It is template class
#ifndef FileHandlerh_h
#define FileHandlerh_h
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
template <class T>
class FileHandler
{
private:
fstream file_;
public:
FileHandler(){};
FileHandler(const char* fname_){fileOpen(fname_);};
void fileOpen(const char* fname_){file_.Open(fname_,ios::in|ios::out|ios::ate|ios::binary);};
void fileWrite(T);
void fileSeekWrite(T,int);
T fileRead(int);
int getNoOfRecords();
~FileHandler(){file_.close();};
};
Help me with this...!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
C++ 区分大小写。您需要使用
open()
而不是Open()
。C++ is case sensitive. You need to use
open()
instead ofOpen()
.也许使用小写
O
?在标准库中的函数名称中很少见大写字母。Use a lowercase
O
, perhaps? It's quite uncommon to see capitals in function names in the standard library.