Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15367
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: memory allocation/deaalocation in calss |
| Date | 2012-04-14 11:29 +1200 |
| Message-ID | <9urr7nFjbhU4@mid.individual.net> (permalink) |
| References | <28714271.3.1334350972034.JavaMail.geo-discussion-forums@pbcuv5> <2177910.9.1334355438050.JavaMail.geo-discussion-forums@pbky1> |
On 04/14/12 10:17 AM, asit wrote:
> Here is the code..
>
> #include<iostream>
>
> using namespace std;
>
> class LinkedList
> {
> struct node
> {
> int data;
> node *next;
> };
>
> node* header;
>
> public:
> LinkedList():header(NULL) {}
> LinkedList(const LinkedList&cp)
> {
> node *t = cp.header, *t2;
> header = NULL;
> while(t != NULL)
> {
> t2 = new node;
> t2->data = t->data;
> t2->next = header;
> header = t2;
> t = t->next;
> }
>
> }
> LinkedList& operator=(const LinkedList&cp)
> {
> if(&cp == this)
> return *this;
> //LinkedList();
> node *t = cp.header, *t2;
> header = NULL;
What happens here if the list isn't empty?
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 14:02 -0700
Re: memory allocation/deaalocation in calss "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 23:35 +0200
Re: memory allocation/deaalocation in calss Ian Collins <ian-news@hotmail.com> - 2012-04-14 09:36 +1200
Re: memory allocation/deaalocation in calss Kevin McCarty <kmccarty@gmail.com> - 2012-04-13 14:35 -0700
Re: memory allocation/deaalocation in calss Juha Nieminen <nospam@thanks.invalid> - 2012-04-14 05:27 +0000
Re: memory allocation/deaalocation in calss Christopher Creutzig <christopher@creutzig.de> - 2012-04-26 19:46 +0200
Re: memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 15:17 -0700
Re: memory allocation/deaalocation in calss Ian Collins <ian-news@hotmail.com> - 2012-04-14 11:29 +1200
Re: memory allocation/deaalocation in calss asit <lipun4u@gmail.com> - 2012-04-13 15:31 -0700
csiph-web