Singly-linked list implementation My code is working now. As you can see in the list.h some type definitions are too long and hard to read. Is there a way to do some short ones? And what happens if the code throws an exception? (I know I will have leaking memory parts) What can I do to collect garbage? And what other functions might be added to code to enhance it?

list.h

#ifndef LIST_H_
#define LIST_H_

#include &lt;iostream&gt;

template &lt;typename T&gt;
class list{
public:
    list();
    ~list();
    class node;
    typedef T           value_type;
    typedef T&amp;          reference;
    typedef node        node_type;
    typedef node_type*  node_pointer;

    list&amp;           push_back(value_type);
    value_type      pop_front();
    node_pointer    begin() const;
private:
    node_pointer    head, tail;
};


template &lt;typename T&gt;
class list&lt;T&gt;::node{
public:
    node(value_type value = 0);
    ~node();
    void            setData(value_type);
    value_type      getData() const;
    void            setNext(node_pointer);
    node_pointer    getNext() const;

private:
    value_type      data;
    node_pointer    ptr_next;
};

template &lt;typename T&gt;
inline list&lt;T&gt;::node::node(value_type value) : data(value), ptr_next(nullptr){
    //std::cout &lt;&lt; "*" &lt;&lt; value &lt;&lt; "\t";
}

template &lt;typename T&gt;
inline list&lt;T&gt;::node::~node(){
    //std::cout &lt;&lt; "node dtor" &lt;&lt; std::endl;
}

template &lt;typename T&gt;
void list&lt;T&gt;::node::setData(value_type value){
    this-&gt;data = value;
}

template &lt;typename T&gt;
typename list&lt;T&gt;::value_type        list&lt;T&gt;::node::getData() const{
    return this-&gt;data;
}

template &lt;typename T&gt;
void list&lt;T&gt;::node::setNext(node_pointer ptr){
    this-&gt;ptr_next = ptr;
}

template &lt;typename T&gt;
typename list&lt;T&gt;::node_pointer  list&lt;T&gt;::node::getNext() const{
    return this-&gt;ptr_next;
}

template &lt;typename T&gt;
list&lt;T&gt;::list() : head(nullptr), tail(nullptr){
    //std::cout &lt;&lt; "list ctor" &lt;&lt; std::endl;
}

template &lt;typename T&gt;
list&lt;T&gt;::~list(){
    list&lt;T&gt;::node_pointer ptr = this-&gt;head, next_ptr;
    while(ptr != nullptr){
        //std::cout &lt;&lt; "@" &lt;&lt; ptr-&gt;getData() &lt;&lt; "\t";
        next_ptr = ptr-&gt;getNext();
        delete ptr;
        ptr = next_ptr;
    }
}

template &lt;typename T&gt;
list&lt;T&gt;&amp;    list&lt;T&gt;::push_back(value_type value){
    node_pointer item = new node_type(value);
    if(this-&gt;tail) this-&gt;tail-&gt;setNext(item);
    this-&gt;tail = item;
    if(!this-&gt;head) this-&gt;head = this-&gt;tail;

    return *this;
}

template &lt;typename T&gt;
typename list&lt;T&gt;::value_type    list&lt;T&gt;::pop_front(){
    if(this-&gt;head){
        node_pointer    item = this-&gt;head;
        value_type      value = this-&gt;head-&gt;getData();

        this-&gt;head = this-&gt;head-&gt;getNext();
        delete item;

        return value;
    }

return 0;
}

template &lt;typename T&gt;
typename list&lt;T&gt;::node_pointer list&lt;T&gt;::begin() const{
    return this-&gt;head;
}

template &lt;typename T&gt;
std::ostream &amp; operator&lt;&lt;(std::ostream &amp;stream, list&lt;T&gt; &amp;obj){
    typename list&lt;T&gt;::node_pointer ptr = obj.begin();
    while(ptr != nullptr){
        stream &lt;&lt; ptr-&gt;getData() &lt;&lt; ' ';
        ptr = ptr-&gt;getNext();
    }
    return  stream;
}

#endif /* LIST_H_ */


main.cpp

int main (int argc, char ** argv){

    list&lt;int&gt; numbers;
    numbers.push_back(3).push_back(5).push_back(11);
    cout &lt;&lt; numbers;

    return 0;
}
Let's answer your questions first:

What about the memory issues?
If you are not limited to an older C++ standard in any way, it would be the best to use C++11 (or above), since it provides you with a good implementation of smart pointers (reference, in-depth-tutorial). This way, all your memory management becomes easier and more resilient. Also you do not need to manually delete anything and do not run into trouble if someone else is still accessing the element you just removed.

Caution: Smart pointers and raw pointers do not mix very well, so avoid raw pointers whenever possible.

What about type definitions?
In general, many people nowadays do frown upon typedefs. Firstly, they hide the actual composition of the type and may lead to confusion or wrong assumptions - especially in team projects. Second, in C++ you do have the using keyword which is a better choice here, especially since it can be combined with templates. (reference)

What functions should be provided?
If there is a push_back I would expect some kind of pop_back (also a push_front). Usually you have some methods to give you the number of elements in the list, check if the list is empty... You can take Qt's QList class as an inspiration ().

Suggestion: make node a templates class
Defining the inner class list&lt;T&gt;::node is valid code and gets the job done. However, you may find that it would be more convenient to pull it out of the list class and define a stand-alone class node&lt;T&gt;. A list&lt;T&gt; then contains a node&lt;T&gt;. Depending on your design, you then might find that your node class then is re-usable e.g. for queues.

Recommendation: Use namespaces
Namespaces are your #1 tool to structure your code. At least one level of namespaces should be used at all times to avoid cluttering the global namespace.

Suggestion: use #pragma once
If your compiler supports it, this is a good alternative to the include guards. Just put it into the first line of your header and you are good to go. 

Hint: inline is not that important
First, do not waste brain capacity on whether to inline something while developing. Early optimization suffocates progress, diverts attention, and thus kills projects. Get it to run, then optimize one step at a time. Second, modern compilers know best what to inline and what not. Let them do it, they are really good at this. While learning, trust your compiler. You can argue with it later :)

Additional note: Combining templates and inline is used to address issues with the One Definition Rule (ODR). If you define a template, but do not fully specialize it, you may (but do not need to) inline. However if you do also want to provide a fully specialized case, you have to inline, otherwise you conflict with the ODR, since the compiler expands the template and thus already provides an implementation for the case you intended to cover "by hand". See also this question for details and examples. (Kudos to @Cody Gray)

Wrapping things up
I just sketched together a piece of code that sums up the made suggestions/ recommendations to give you an orientation (Note: I prefer the Java-style of camel-casing the type names with an initial upper case letter, but this is a question of personal preference).

#pragma once

#include &lt;memory&gt; // for smart pointers

namespace collection {

template&lt;typename ValueType&gt;
class Node&lt;ValueType&gt; {

private:
    ValueType _data; 
    // alternatively store a smart pointer to the data 
    // if the amount of data is large e.g. an image
    std::shared_ptr&lt;Node&lt;ValueType&gt;&gt; _next;
    // to "delete" the next pointer just reset it to nullptr
    // only hand out the shared pointer, never the thing it points to
    // the receiver has to check if the pointer is null before use
public: 
     //... you know what to do
};

template&lt;typename ValueType&gt;
class List&lt;ValueType&gt; {

private:
    std::shared_ptr&lt;Node&lt;ValueType&gt;&gt; _head;
    // you can also keep track of the tail and whatever...
public:
    // ... all the functions
};

} // end namespace collection


Last but not least
Put your code somewhere accessible (e.g. github) which makes it easier to review code, suggest concrete changes, discuss details, and notify you about the bugs and issues that were found. Post a link and I will have a look at it :)