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...!!
C++ is case sensitive. You need to use open()
instead of Open()
.
Use a lowercase O
, perhaps? It's quite uncommon to see capitals in function names in the standard library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.