M
MA
Hello,
I've a question that I really don't know how to do a search for on the
internet. The project I'm working on now is one of my first
C++-projects, earlier I've been using C and Java (and VB when forced
to).
According to my C++ book theese instantiations are equivalent:
MyClass mc(a, b);
MyClass mc = MyClass(a, b);
In my project I have a class named FileReader which I'm trying to
instantiate. Using this method it works fine:
char *filename = "c:/temp/testfile.txt";
FileReader fr(filename, 10);
....but if I use this method it doesn't:
char *filename = "c:/temp/testfile.txt";
FileReader fr = FileReader(filename, 10);
The error messages from the compiler are the following:
------------------------------------------------------------
g++.exe -D__DEBUG__ -c main.cpp -o
ain.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I
"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include" -g3
C:/Dev-Cpp/include/c++/bits/ios_base.h: In copy constructor
`std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)':
C:/Dev-Cpp/include/c++/bits/ios_base.h:421:
`std::ios_base::ios_base(const
std::ios_base&)' is private
main.cpp:92: within this context
C:/Dev-Cpp/include/c++/streambuf: In copy constructor
`std::basic_filebuf<char,
std::char_traits<char> >::basic_filebuf(const
std::basic_filebuf<char,
std::char_traits<char> >&)':
C:/Dev-Cpp/include/c++/streambuf:486: `std::basic_streambuf<_CharT,
_Traits>::basic_streambuf(const std::basic_streambuf<_CharT,
_Traits>&)
[with _CharT = char, _Traits = std::char_traits<char>]' is private
main.cpp:92: within this context
make.exe: *** [main.o] Error 1
Execution terminated
I've a question that I really don't know how to do a search for on the
internet. The project I'm working on now is one of my first
C++-projects, earlier I've been using C and Java (and VB when forced
to).
According to my C++ book theese instantiations are equivalent:
MyClass mc(a, b);
MyClass mc = MyClass(a, b);
In my project I have a class named FileReader which I'm trying to
instantiate. Using this method it works fine:
char *filename = "c:/temp/testfile.txt";
FileReader fr(filename, 10);
....but if I use this method it doesn't:
char *filename = "c:/temp/testfile.txt";
FileReader fr = FileReader(filename, 10);
The error messages from the compiler are the following:
------------------------------------------------------------
g++.exe -D__DEBUG__ -c main.cpp -o
ain.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I
"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include" -g3
C:/Dev-Cpp/include/c++/bits/ios_base.h: In copy constructor
`std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)':
C:/Dev-Cpp/include/c++/bits/ios_base.h:421:
`std::ios_base::ios_base(const
std::ios_base&)' is private
main.cpp:92: within this context
C:/Dev-Cpp/include/c++/streambuf: In copy constructor
`std::basic_filebuf<char,
std::char_traits<char> >::basic_filebuf(const
std::basic_filebuf<char,
std::char_traits<char> >&)':
C:/Dev-Cpp/include/c++/streambuf:486: `std::basic_streambuf<_CharT,
_Traits>::basic_streambuf(const std::basic_streambuf<_CharT,
_Traits>&)
[with _CharT = char, _Traits = std::char_traits<char>]' is private
main.cpp:92: within this context
make.exe: *** [main.o] Error 1
Execution terminated