0

I was reading something before about linked lists in C++ and something that I hadn't seen before appeared to me. The link that I was reading is this. The section of code in which this appeared is:

class LinkedList
{
  // private member variables of the class 
  int data;
  Node *next;
  //...
public:
  // constructor: put the object in a known state
  LinkedList() : data(0), next(nullptr) {}
  //...
};

I don't understand the use of data(0), next(nullptr) after the declaration of the constructor. What does it do? And is it something exclusive of constructors, or could it be used in other class functions?

0 Answers0