Link to home
Start Free TrialLog in
Avatar of lost_bits1110
lost_bits1110

asked on

want to declare an ifstream as part of my class

hello

whne I declare a member of type ifstream in my class, I get errors such as:

error: within this context
/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c++/3.4.2/streambuf: In member function `std::basic_filebuf<char, std::char_traits<char> >& std::basic_filebuf<char, std::char_traits<char> >::operator=(const std::basic_filebuf<char, std::char_traits<char> >&)':
/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c++/3.4.2/streambuf:776: error: `std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]' is private

and this happens if I just declare something of type ifstream as one of my public member variables , like so:

#include <iostream>
#include <fstream>
using namespace std;

class SOMECLASS
{
    void blabla()
    ifstream infile;
};

I'm on a linux, why doesnt it like this?????
Thank you in advance!!
LD
Avatar of lost_bits1110
lost_bits1110

ASKER

ok i realize now i dont need to declare it in my file but now i get

*** glibc detected *** double free or corruption:

ASKER CERTIFIED SOLUTION
Avatar of Manish Chhetia
Manish Chhetia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you echo the lib path