c++ - What does a single colon introduce as part of a constructor? -


this cpp source file:

class classname{      //constructor     classname(anotherclass *ptr);      private:         string firstname;         string lastname;  };  classname::classname(anotherclass *ptr): firstname("nathan"), lastname("narcovy"){      //some other definitions  } 

i come c, know bit of object oriented language,
don't understand classname:string,string . remember colon : used inheritance.

this how initializer list works constructor.

i've found this tutorial seems explain decently newcomer.


Comments