Using the following class fragment note that the data is sto

Using the following class fragment (note that the data is stored indirectly using a pointer in the node): class List {private: struct Node {NodeData *data; Node *next;}; Node *head;}; Write the copy constructor for this class. Do not use any other methods in your implementation, except that you may use the copy constructor for the NodeData class.

Solution

An example below shows the use of copy constructor:


class List {
private:
struct Node {
List value;
Node *next;
Node(List val1, Node *nxt1=NULL) {
value = val1;
next = nxt1;
}
};
Node *head;
public:
List();
List(List &obj);
~List();

};

 Using the following class fragment (note that the data is stored indirectly using a pointer in the node): class List {private: struct Node {NodeData *data; Nod

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site