title: Is it possible to create a linked list that can hold pointers instead of integers or string?
body: <p>I'm new to programming but I have a question about linked lists. I am creating a double linked list and I want my nodes to store pointers not just strings or ints. Would code like this work?</p>
  
  <pre><code>template &lt;typename T&gt;
  class LinkedList
  {
  private:
      struct Node {
          string name;
          int age;
          int location;
          Node* next;
          Node* previous;
          Node(T info){ name = info-&gt;getName(); age = info-&gt;getAge; location = info-&gt;getLocation; next = NULL; previous = NULL; }
  
  
      };
      Node* head = NULL;
      Node* tail = NULL;
  </code></pre>
  
  <p>This is assuming that (T info) is a pointer to a class object that has been created from:</p>
  
  <pre><code>#include "Person.h"
  
  
  Person::Person(string name, int age, int location)
  {
      this-&gt;name = name;
      this-&gt;age = age;
      this-&gt;location = location;
  }
  
  
  Person::~Person()
  {
  }
  
  string Person::getName()
  {
      return name;
  }
  
  int Person::getAge()
  {
      return age;
  }
  
  int Person::getLocation()
  {
      return location;
  }
  </code></pre>
  
  <p>I want to be able to create a Person from my person class and then store that person (name, age, and location) in my linked list:</p>
  
  <pre><code>Person* newPerson = new Person(name, age, location);
  LL.insert(newPerson);
  </code></pre>
  
  <p>LL is a linked list I created inside my main.cpp and insert is a function of my linked list.</p>
  
  <p>Maybe this isn't the best way to do this but can I do this?</p>