problem regarding overloading of operator <<.

A

Ashwin

FamilyNet International Newsgate

From: "Ashwin" <[email protected]>




Kai-Uwe Bux said:
Ashwin said:
Ian said:
Ashwin wrote:

hi guys ,

sorry to disturb you again . can any one explain me this error

I thought you were going to fix your capitalisation?

/usr/include/c++/3.2.2/bits/stl_construct.h: In function `void
std::_Construct(_T1*, const _T2&) [with _T1 = student, _T2 =
student]':
/usr/include/c++/3.2.2/bits/stl_list.h:328: instantiated from
`std::_List_node<_Tp>* std::list<_Tp, _Alloc>::_M_create_node(const
_Tp&) [with _Tp = student, _Alloc = std::allocator<student>]'
/usr/include/c++/3.2.2/bits/stl_list.h:430: instantiated from
`std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp,
_Alloc>::insert(std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&) [with
_Tp = student, _Alloc = std::allocator<student>]'
/usr/include/c++/3.2.2/bits/stl_list.h:479: instantiated from `void
std::list<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = student,
_Alloc = std::allocator<student>]'
assign2.cpp:100: instantiated from here
/usr/include/c++/3.2.2/bits/stl_construct.h:78: no matching function
for call
to `student::student(const student&)'
assign2.cpp:80: candidates are: student::student()
assign2.cpp:8: student::student(student&)

The compiler is telling you that student doesn't have a copy
constructor. Any user defined type used with a standard container must
have a public copy constructor if any other constructor is declared
because the object is copied into the container.

thanks Ian Collins for replying.but when i used the standard string
class without any copy constructor for the student class it didn't give
me errors why is it giving error now.

The error is somewhere in the code you did not post. Read the FAQ about how
to post. It will tell you to provide enough code for us to reproduce the
problem.

If it works with std::string instead of string1, then chances are, your
string1 class is broken and we might be seeing errors that manifest
themselves elsewhere.

Also, I doubt that you did not declare a copy constructor for student. The
compiler tells us that there is a constructor:

student::student(student&);

which qualifies as a copy constructor. However, it is not const-correct. Try

strudent( student const & );

instead.


Also, does your string1 class have a copy constructor? Is it written
const-correctly?


Best

Kai-Uwe Bux

Thanks Kai-Uwe Bux. As you said the copy constructor is strudent(
student & ) if i use const qualifier there will be errors as i
haven't used const in the copy constuctor of string1 .so i have to
change many things in my string and linked list class.I have not used
this const qualifier regulerly so these many problems. Thanks for
replying .

Thanks and Regards
Ashwin

FamilyNet <> Internet Gated Mail
http://www.familynet-international.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top