Skip to content

Instantly share code, notes, and snippets.

@Superbil
Created August 9, 2011 13:01
Show Gist options
  • Save Superbil/1133977 to your computer and use it in GitHub Desktop.
Save Superbil/1133977 to your computer and use it in GitHub Desktop.
#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