Skip to content

Instantly share code, notes, and snippets.

@bioball
Last active December 28, 2015 01:24
Show Gist options
  • Save bioball/79f7305926fb6eac8e56 to your computer and use it in GitHub Desktop.
Save bioball/79f7305926fb6eac8e56 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template<class T>
class LinkedList
{
private:
T* value;
LinkedList* nextNode = nullptr;
public:
LinkedList (T* val)
{
value = val;
}
LinkedList* next()
{
return nextNode;
}
void append(T* val)
{
nextNode = new LinkedList(val);
}
T* get ()
{
return value;
};
};
class Person
{
public:
string firstName;
string lastName;
Person (string fName, string lName)
{
firstName = fName;
lastName = lName;
}
};
int main()
{
Person peter ("Peter", "Pan");
Person paul ("Paul", "George");
LinkedList<Person> foo (&peter);
foo.append(&paul);
Person* result = foo.next() -> get();
cout << result->firstName << endl;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment