?
Solved

Copy Constructor on Linked List

Posted on 2003-02-20
2
Medium Priority
?
236 Views
Last Modified: 2010-04-01
Dear *

Let's say I have :
class Node  {int item; Node * nnext; };
class List {int size; Node * front, * rear; List * lnext };

How to create a copy constructor and an operator= overloading for CLASS List ? What's difference between both ?

Notes : Definitely a created list will have collection of nodes and every list later will be connected to another list object.

Thanks for ur code.
0
Comment
Question by:asampadeh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
Rabo earned 60 total points
ID: 7989530
>How to create a copy constructor and an operator= overloading ?
For the Node or the List class?

>What's difference between both ?
The copy constructor constructs a new class
and initializes it, given an existing reference.

The assignment operator is no constructor.
(= It doesnt construct anything newly, but
assigns existing things as you see above)
0
 

Author Comment

by:asampadeh
ID: 8128913
I study more and I understand. Thanks Rabo.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question