Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- template <typename T>
- class node {
- public:
- T data;
- node *next;
- node() :
- data( T() ), next( this ) { }
- node(const T& data, node* next) :
- data ( T(data) ), next( next ) { }
- };
- int main() {
- node<int> *front;
- front = new node<int>(10,
- new node<int>(20,
- new node<int>(30,
- new node<int>(40,NULL)
- )
- )
- );
- //----------- write your code here ------------
- // write code here such that
- // display will show 10, 30
- front->next=front->next->next;
- front->next->next=NULL;
- //------------------- display --------------------
- node<int> *p = front;
- int i = 0;
- while (p!=NULL) {
- cout << i << ":" << p->data << endl;
- p = p->next;
- i++;
- }
- }
Add Comment
Please, Sign In to add comment