-2

I have problems understanding the following C++ code. Can somebody please explain to me the meaning of the line 3? What does ": lmp(ptr)" before constructer mean?

I cannot make sense out of it

class Pointers {
 public:
  Pointers(TYPE* ptr) : lmp(ptr)
    {}
  virtual ~Pointers() {}
 protected:
  TYPE* lmp;
};

}
Lawless
  • 75
  • 1
  • 5

1 Answers1

1
 : lmp(ptr)

is called constructor initialization list. It will initialize lmp with ptr. See this link for some understanding: What is constructor initialization list and why should I use it

taocp
  • 23,276
  • 10
  • 49
  • 62