c++ - Regarding ifstream: error ‘std::ios_base::ios_base(const std::ios_base&)’ is private -


i getting error in title, when try following.

class test { private:     std::ifstream file;   public:     test(); 

};

test::test() {}

i know there many threads on stack issue. know can resolve issue simple as

std::ifstream *file; 

the reason have posted question because instructor has told me should able without modifying first code block posted. i've researched this, , haven't found suggests can. ideas?

as requested.

class test { private:     std::ifstream file;   public:     test(); };  test::test() {}  int main() { test test = test(); return 0; } 

that example of can't compile.

the line

test test = test(); 

is problem since std::ifstream not have copy constructor or copy assignment operator. use:

test test; 

if have c++11 compiler, can use:

test test{}; 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -