Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class MyList
- {
- public:
- struct element {
- int value;
- element *next;
- };
- element *head;
- MyList() {
- head = NULL;
- }
- void Add(int x) {
- element *temp = new element;
- temp->value = x;
- temp->next = head;
- head = temp;
- };
- void Show() {
- element *temp = head;
- while (temp != NULL) {
- cout << temp->value << " ";
- temp = temp->next;
- }
- };
- };
- int main() {
- MyList list;
- list.Add(2);
- list.Add(3);
- list.Show();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement