following code for some reason, causes following errors withing its include files, when compiled with microsoft visual c++:
1>c:\program files\microsoft visual studio 9.0\vc\include\istream(846) : error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : no accessible path to private member declared in virtual base 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ios(152) : see declaration of 'std::basic_ios<_Elem,_Traits>::operator ='
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator =(const std::basic_istream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\fstream(548) : error C2248: 'std::basic_streambuf<_Elem,_Traits>::operator =' : cannot access private member declared in class 'std::basic_streambuf<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\streambuf(22) : see declaration of 'std::basic_streambuf<_Elem,_Traits>::operator ='
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_filebuf<_Elem,_Traits> &std::basic_filebuf<_Elem,_Traits>::operator =(const std::basic_filebuf<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\ostream(584) : error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : no accessible path to private member declared in virtual base 'std::basic_ios<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ios(152) : see declaration of 'std::basic_ios<_Elem,_Traits>::operator ='
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> This diagnostic occurred in the compiler generated function 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator =(const std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <fstream>
#include <iostream>
#include <cstring>
using namespace std;
const int MAX_CONT = 400;
class file{
public:
file(const char fileName[]);
file();
char *getcontents();
bool open(char *file);
bool save(char *contents);
void close();
protected:
char filename[24];
ifstream in;
ofstream out;
};
bool file::save(char *contents){
if (!out){
return false;
}
int i; for(i=0;contents[i];i++) out.put(contents[i]);
return true;
}
bool file::open(char *file){
in.close();
out.close();
strcpy(filename,file);
in = ifstream(filename);
out = ofstream(filename);
if (!in | !out){
return false;
}
return true;
}
void file::close(){
in.close();
out.close();
}
char *file::getcontents(){
char c[MAX_CONT] = "";
in.get(c,MAX_CONT);
return c;
}
file::file(const char fileName[]){
strcpy(filename,fileName);
in = ifstream(filename);
out = ofstream(filename);
}
|
what am i doing wrong?