Click here to Skip to main content
15,879,490 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I tried as below, but ostream cannot be instantiate?
ifstream ifs1("file1");<br />ifstream ifs2("file2");<br />ostream oss;<br />oss << ifs1 << ifs;
Posted

1 solution

ostream is an abstract base class - that's why you can't instantiate it. Also, you can't use the insertion operator on streams to get what you're wanting.

So...what do you mean by "memory binary stream"? If you were using strings, then this should work:

ifstream ifs1("file1");<br />ifstream ifs2("file2");<br />ostringstream oss;<br />std::copy(std::istream_iterator<char>(ifs1), std::istream_iterator<char>(), std::ostream_iterator<char>(oss));<br />std::copy(std::istream_iterator<char>(ifs2), std::istream_iterator<char>(), std::ostream_iterator<char>(oss));


 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900