|
From: Patel, N. M <Nil...@qu...> - 2004-10-28 14:55:47
|
I came across some code references online, and trying to figure out what = does=20 ' +=3D ' stand for. e.g. firstnamelength +=3D 10; =3F=3F=3F=3F -----Original Message----- =46rom: dev...@li... [mailto:dev...@li...]On Behalf Of dev...@li... Sent: Wednesday, October 27, 2004 11:26 PM To: dev...@li... Subject: Dev-cpp-users digest, Vol 1 #2200 - 1 msg Send Dev-cpp-users mailing list submissions to dev...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/dev-cpp-users or, via email, send a message with subject or body 'help' to dev...@li... You can reach the person managing the list at dev...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Dev-cpp-users digest..." Today's Topics: 1. Re: Using Templates & Constructors (Siva Chandra) --__--__-- Message: 1 Date: Tue, 26 Oct 2004 21:36:20 -0700 (PDT) =46rom: Siva Chandra <siv...@ya...> Subject: Re: [Dev-C++] Using Templates & Constructors To: dev...@li... Hello,=20 As we can see the compiler complains about the class definition in the *.cpp file. > \myFolder\myClass.cpp In constructor > `myClass<Type>::myClass(const Type&)': >=20 > 7 \myFolder\myClass.cpp syntax error before `;' > token=20 > \myFolder\Makefile.win [Build Error] [myClass.o] > Error 1=20 And, the complaint is about the way you have created a new myClass object. Firtsly, you have declared a protected member object of type Type in the class declaration and not a pointer to an object of type Type. So I guess the declaration code should be changed to: Type* count; // Declare count as a pointer. Next, even after making such a correction, the way you should go about initialising this object is: count =3D new Type(item); and not as: count =3D new Type item; Even here, the class of type Type should have a logically correct copy constructor. > Lastly, here is my myClass.cpp code: > _____________________ > #include <iostream> > #include "myClass.h" > =20 > template<class Type> > myClass<Type>::myClass(const Type &item) //default > constructor > { > count =3D new Type item; > } Hope this helps, Siva Chandra =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D The contents of this message, together with any attachments, are intended = only for the use of the person(s) to which they are addressed and may = contain confidential and/or privileged information. Further, any medical = information herein is confidential and protected by law. It is unlawful for= = unauthorized persons to use, review, copy, disclose, or disseminate = confidential medical information. If you are not the intended recipient, = immediately advise the sender and delete this message and any attachments. = Any distribution, or copying of this message, or any attachment, is = prohibited. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D |