Created
August 9, 2011 13:01
-
-
Save Superbil/1133977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
template <class LType> | |
class Node | |
{ | |
public: | |
LType data; | |
Node<LType>* pret; | |
Node<LType>* next; | |
Node(const LType &, Node<LType>* , Node<LType>*); | |
}; | |
template <class LType> | |
Node<LType>::Node(const LType &obj, Node<LType>* p, Node<LType>* n) | |
{ | |
data = obj; | |
pret = p; | |
next = n; | |
} | |
template <class LType> | |
class List | |
{ | |
private: | |
Node<LType> *first; | |
Node<LType> *last; | |
public: | |
List(); | |
void push_back(const LType); | |
LType pop_back(); | |
}; | |
template <class LType> | |
void List<LType>::push_back(const LType data) | |
{ | |
first = new Node<LType>(data,NULL,NULL); | |
} | |
template <class LType> | |
LType List<LType>::pop_back() | |
{ | |
return first->data; | |
} | |
int main(int argc, const char *argv[]) | |
{ | |
List<int>* list = new List<int>(); | |
list->push_back(10); | |
printf("%d",list->pop_back()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment