Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
LinkedList
#include <iostream> using namespace std; class LinkedList; class Node { friend class LinkedList; private: int data; Node *next; }; class LinkedList() { private: Node *head; public: LinkedList { head = 0; } ~LinkedList() { Node *curr = head; Node * temp; while(curr!=0) { temp = curr->next; delete curr; curr = temp; } head = 0; } bool InsertAtStart(int val) { Node *temp = new Node; if(temp!=0) { temp->data = val; temp->next = 0; head = temp; return true; } else { return false; } } bool InsertAtEnd(int val) { Node *temp = new Node; Node *curr = head; Node *prev = 0; if(temp!=0) { temp->data = val; temp->next = 0; while(curr!=0) { prev = curr; curr = curr->next; } if(prev == 0) { head = temp; } else { prev->next = temp; } return true; } else { return false; } } void display() { Node *curr = head; while (curr!=0) { cout << curr; curr = curr->next; } } }; int main() { cout << "Hello World" << endl; }
run
|
edit
|
history
|
help
0
ria
Wide string conversion with multibyte chars and locale + concatenation
cv4_template
RecursiveDivide
not a parameter pack
Program of cube
hangman
CommandQueue
MSVC14 <exception> header
virtual inheritance