Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello new to programming trying to create a copy constructor and a destructor fo

ID: 670667 • Letter: H

Question

Hello new to programming trying to create a copy constructor and a destructor for a single linked list in c++, cant really figure it our. This is my header file:

#include <iostream>
#include <string>

using namespace std;

#ifndef LIST_H
#define LIST_H

class node
{
public:
   char word; //data element
    node *next; //pointer element
};

//declaration of a list class
class LIST
{
public:
   LIST(); //default constructor
    LIST(const LIST & org); //copy constructor
   ~LIST(); //destructor
    LIST(const string &); //explicit-value constructor
   bool IsEmpty();
   bool IsEqual();
   int Length();
   void Insert(const char &);
   void Remove(const char &);
   void Remove_All(const char &);
LIST & operator+(const WORD & Org);
LIST & operator=(const char &);
    LIST & operator=(const WORD & Org); //With Chaining
   friend ostream & operator<<(ostream &, const LIST &);
private:
    node *front, *back;
};

#endif

Have to turn this in soon any help is appreciated. Thanks

Explanation / Answer

}

LIST(const string & cpy){

node * t;

front = cpy;

t = front;

while(cpy != 0 ) t->next = cpy-next, cpy = cpy->next;
//front

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote