N
N
Nikita Kolosov2011-09-12 15:29:28
C++ / C#
Nikita Kolosov, 2011-09-12 15:29:28

C++ compilation error

When writing
#include and trying to compile, the following message appears:

/usr/include/c++/4.5/bits/ios_base.h: In copy constructor 'std::basic_ios::basic_ios(const std::basic_ios&)':
/usr/include /c++/4.5/bits/ios_base.h:785:5: error: 'std::ios_base::ios_base(const std::ios_base&)' is private
/usr/include/c++/4.5/iosfwd:77:11: error: within this context
/usr/include/c++/4.5/iosfwd: In copy constructor 'std::basic_ifstream::basic_ifstream(const std::basic_ifstream&)':

/usr/include/c++/4.5/iosfwd:111:11: note: synthesized method 'std::basic_ios::basic_ios(const std::basic_ios&)' first required here
/usr/include/c++/4.5/streambuf: In copy constructor 'std::basic_filebuf::basic_filebuf(const std::basic_filebuf&)':
/usr/include/c++/4.5/streambuf:773:7: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf( const std::basic_streambuf<_CharT, _Traits>::__streambuf_type&) [with _CharT = char, _Traits = std::char_traits, std::basic_streambuf<_CharT, _Traits>::__streambuf_type = std::basic_streambuf]' is private /usr /include/c++/4.5/iosfwd:111:11: note: synthesized method 'std::basic_filebuf::basic_filebuf(const std::basic_filebuf&)' first required here main.cpp: In function 'int main(int, char* *)':
/usr /include/c++/4.5/iosfwd:108:11: error: within this context
/usr/include/c++/4.5/iosfwd: In copy constructor 'std::basic_ifstream::basic_ifstream(const std::basic_ifstream&)':
main.cpp:27:54: note: synthesized method 'std::basic_ifstream::basic_ifstream(const std::basic_ifstream&)' first required here
main.cpp:27:54: error: initializing argument 1 of 'void Replace::replace_strings(std::ifstream, std::ofstream, std::string, std::string)'
make: *** [main.o] Error 1

if I remove this Include, messages like error are displayed : variable 'std::ifstream fin' has initializer but incomplete type, which is obvious

$g++ --version
g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

How do I get rid of this error?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gribozavr, 2011-09-12
@Anexroid

[telepath mode on]
Header file, probably fstream. The problem is most likely that you are passing std::ifstream to the function by value, not by reference.

I
ixSci, 2011-09-12
@ixSci

What do you think yourself, according to the data you provided and without a crystal ball, you can determine the error?
What is "this inclusion". Can't you call it? (Or habroparser ate :)?)
Where is the code that you have in main?

A
Anatoly, 2011-09-12
@taliban

I don’t rummage in C++, but phrases like “error: blah blah is private” suggest that you are trying to access private methods =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question