#include using namespace std; class linkedListclass { friend class realList; public: linkedListclass(int newvalue) { dvalue=newvalue; next = NULL; } void printlist() { cout << "current node is " << dvalue << endl; if (next != NULL) next->printlist(); else cout << "\n\n"; } private: int dvalue; linkedListclass *next; }; class realList { public: realList(int nodevalue) { first = new linkedListclass(nodevalue); } ~realList() { linkedListclass *temp; cout << "called the destructor for realList \n"; while (first != NULL) { temp = first; first = first -> next; cout << "deleting " << temp->dvalue << endl; delete temp; } } void addbehind(int newvalue) { linkedListclass *newnode = new linkedListclass(newvalue); first->next = newnode; } void addinfront(int newvalue) { linkedListclass *newnode = new linkedListclass(newvalue); newnode->next = first; first = newnode; } int getdvalue() { return(first->dvalue); } void printlist() { first->printlist(); } private: linkedListclass *first; }; int main() { realList *myList; myList= new realList(23); cout << "The value is " << myList->getdvalue() << endl; myList->addbehind(45); myList->printlist(); myList->addinfront(10); myList->printlist(); delete myList; return 0; }