#include using namespace std; class linkedListClass { friend class realList; public: linkedListClass(int newvalue) { dvalue=newvalue; next = NULL; } private: int dvalue; linkedListClass *next; }; class realList { public: realList() { first = NULL; } realList(int nodevalue) { first = new linkedListClass(nodevalue); } void addbehind(int newvalue) { linkedListClass *newnode = new linkedListClass(newvalue); if (first == NULL) first = newnode; else { newnode->next = first->next; first->next = newnode; } } void addinfront(int newvalue) { linkedListClass *newnode = new linkedListClass(newvalue); if (first == NULL) first = newnode; else { newnode->next = first; first = newnode; } } int getdvalue() { if (first == NULL) return -1; else return(first->dvalue); } void printlist() { linkedListClass *currentNode; if (first == NULL) cout << "The List is currently empty.\n"; else { currentNode = first; cout << "\nHere is the current list: \n"; while (currentNode != NULL) { cout << "\tcurrent node is " << currentNode->dvalue << endl; currentNode = currentNode->next; } } } private: linkedListClass *first; }; int main() { realList *myList; myList= new realList(); myList->addbehind(23); cout << "From main: \n\tthe value is " << myList->getdvalue() << endl; myList->addbehind(45); myList->printlist(); myList->addinfront(10); myList->printlist(); return 0; }