Trying to learn C ++ constructors, why in this example is there two points in the constructor?

advertisements
template<class T>
Queue<T>::Queue(): frontPtr(NULL), backPtr(NULL), count(0)
{
}

Why is it Queue(): and not just Queue()?


The colon indicates the initializer list of your constructor.
It enables you to value-initialize the member variables of your class.

The below is approximately similar (but less efficient than Initializer List):

template<class T>
Queue<T>::Queue()
{
 frontPtr = NULL;
 backPtr = NULL;
 count = 0;
}