C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problem regarding overloading of operator <<.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Ashwin
Guest





PostPosted: Fri Jul 28, 2006 9:10 am    Post subject: problem regarding overloading of operator <<. Reply with quote



FamilyNet International Newsgate

From: "Ashwin" <ashwin.bevinje (AT) gmail (DOT) com>




Kai-Uwe Bux wrote:
Quote:
Ashwin wrote:


Ian Collins wrote:
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.


--
Ian Collins.

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.