C++ Linked List Implementation I'm learning C++ and also about data structures, so I am trying to implement some. This is my linked list. I've included two different ways of getting the length of the list, with a length variable and also a function (getLength2) that goes through the list until it finds a NULL pointer. I suspect that there could be memory leaks in it, though I'm not sure.

    #include "stdafx.h"
    #include &lt;iostream&gt;
    using namespace std;

    template &lt;class val&gt;
    class linked_list{
        struct node{
            val value;
            node *next;
        };
        node *start;
        unsigned int length;
    public:
        linked_list() { length = 0; start = NULL; }
        unsigned int getLength() { return length; }
        val getFirst() { return (*start).value; }
        unsigned int getLength2();
        void add(val value);
        val getVal(unsigned int pos);
        val pop();
    };

    int _tmain(int argc, _TCHAR* argv[])
    {
        linked_list&lt;int&gt; gary;
        for (int i = 0; i &lt; 10; ++i){
            gary.add(pow(2, i));
        }
        for (int k = 0; gary.getLength() &gt; 0; ++k){
            cout &lt;&lt; gary.pop() &lt;&lt; ' ' &lt;&lt; gary.getLength() &lt;&lt; endl;
        }
        return 0;
    }

    template &lt;class val&gt;
    void linked_list&lt;val&gt;::add(val value){
        node *second = start;
        start = new node;
        (*start).value = value;     
        (*start).next = second;
        length += 1;
    }

    template &lt;class val&gt;
    val linked_list&lt;val&gt;::getVal(unsigned int pos){
        node current = *start;
        for (unsigned int depth = 0; depth &lt; pos; ++depth){
            current = *(current.next);
        }
        return current.value;
    }

    template &lt;class val&gt;
    val linked_list&lt;val&gt;::pop(){
        val ret = start-&gt;value;
        node *new_address = start-&gt;next;
        delete start;
        start = new_address;
        length -= 1;
        return ret;
    }

    template &lt;class val&gt;
    unsigned int linked_list&lt;val&gt;::getLength2() {
        if (start == NULL){
            return 0;
        }
        node current = *start;
        unsigned int len = 1;
        while (current.next != NULL){
            current = *(current.next);
            len += 1;
        }
        // should this have a 'delete current'?
        return len;
    }
Your "getters" should be const since they don't modify any data members.  This will also protect you against any accidental modifications in those functions.

unsigned int getLength() const { return length; }

The constructor can instead be an initializer list:

linked_list() : length(0), start(NULL) {}

Be aware of the issues regarding using namespace std.
If you have a C++11-compliant compiler, use nullptr instead of NULL.
Be aware that _tmain() and _TCHAR* are non-portable, so anyone using this code outside of Visual Studio will not be able to compile it.  In order to make this portable, change them to main() and char* respectively.
Since you're using std::pow(), you should include &lt;cmath&gt;.  Although &lt;iostream&gt; is already covering it, you should add this library anyway.
There's not really a need for getLength2().  You just need to increment or decrement length, depending on the list operation.  Your inline "getter" will, of course, return this updated length.

Regarding incrementing/decrementing, length += 1 and length -= 1 can respectively be length++ and length--.
The val argument for add() should be passed by const&amp;, especially if it happens to be of a non-primitive type.
You should consider error-checking (empty list) in pop() if you'd still like it to return the popped value.  Otherwise, you can make it void and simply return if the list is already empty.
Instead of (*start).value, use the -&gt; operator for readability: start-&gt;value.