Answer to Question #82355 in C++ for ana rodriguez

Question #82355
//Answer Code attached; I try to compile it but it doesn't work

#include<iostream>

#include<ctime>

#include <string>

using namespace std;

class List

{

struct Node

{

int data;

Node *next;

};

Node *head;

public:

List()

{

head = NULL;

}

~List()

{ // delete the list while(head != NULL) {

Node * n = head->next;

delete head;

head = n;

}

void add(int value)

{

Node * n = new Node;

n->data = value;

n->next = head;

head = n;

}

void show()

{

while(head !=NULL)

{

Node * n = head->next;

cout<< head->data <<", "; head = n;

}

cout << endl;

}

};

int main()

{

time_t t=time(NULL);

List MyList;

MyList.add(5);

MyList.add(12);

MyList.add(24);

MyList.add(32);

MyList.add(47);

MyList.add(54);

MyList.add(65);

MyList.show();

cout<<"Today is: "<< ctime(&t) << endl;

system("pause");

return 0;

}
1
Expert's answer
2018-10-24T05:38:45-0400
Dear ana rodriguez, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS