Q:

Confused on purpose/meaning of code in C++ struct declaration

I am trying to implement a stack from scratch, and I got things working. However, to get things to compile I needed to add a couple of lines of code which I have no clue about. The stack is built using a linked list. I made a struct for the list nodes as follows:
struct node // linked list node so store stack elements
{
    T value; // value to be store
    node *next; // pointer to next node
};

But this did not compile. After doing some search I came up with this.
struct node // linked list node so store stack elements    
{
    T value; // value to be stored
    node *next; // pointer to next node

    node(const T& newValue, node *nextNode) // ?what does this do?
        : value(newValue), next(nextNode) {} // ?what does this do?
};

I do not know why this is needed to compile, what it does and am particularly confused by the ':' operator as I have yet to come across it in learning C++.
Here is all of the code in case it is useful.
Stack.h
#include <iostream>

template <class T>
class Stack
{
    public:
    Stack() // constructor
    {
            t = NULL; // set bottom of stack to NULL
    }
    ~Stack() // destructor
    {
            while(!empty()) // loop to empty out stack
            {
                    pop();
            }
    }

    void push(const T& a); // add element to top of stack
    T pop(); // remove element from top of stack
    const T& top(); // return element at top of stack
    bool empty(); // check if stack is empty

    private:
    struct node // linked list node so store stack elements
    {
            T value; // value to be stored
            node *next; // pointer to next node
                    node(const T& newValue, node *nextNode) // ?what does this do?
                    : value(newValue), next(nextNode) {} // ?what does this do?
    };

    node *t; // initialize top of stack 
};

template <class T>
void Stack<T>::push(const T& a)
{
    t = new node(a, t); // set new top element, old top element pointer becomes next
}

template <class T>
T Stack<T>::pop()
{
    if(t != NULL)
    {
        node *trash = t; //hold old top node
        t = t->next; // assign new top node
        T popped = trash->value; // store old node value
        delete trash; // delete old top node
        return popped; // return old node value 
    }
}

template <class T>
const T& Stack<T>::top()
{
    if (t != NULL)
    {
        return t->value; // return top element value
    }
    else
    {
        std::cout << "StackException: Empty Stack\n"; //?how can I end the program here?
    }
}

template <class T>
bool Stack<T>::empty()
{
    return t == NULL; // test to see if the stack is empty
}

A:

The member function that you have defined (node(...)) is a constructor and lets the compiler know what to do when you create an object on type node. For example, in your code, you use this statement in your push function: t = new node(a, t);. Compiler has to know how to create a new node with the two arguments passed to it.
In your constructor you need to initialize the class members. Something like:
node(const T &newvalue, node *nextnode)
{
    value = newvalue;
    next = nextnode;
}

But when the compiler uses this on the line node(a, t), it is going to default-initialize value and next first, then assign the correct values inside the constructor. Using the constructor initializing list lets the compiler initialize those members the first time. It can be a means to improve performance if objects of type T are expensive to construct. There are other benefits that you gain by using constructor initializing list and you'll probably come across them as you learn more about C++.

