So I was editing a boilerplate cpp code for a coursera assignment and came across a rather unfamiliar syntax:
pl2_ranker::pl2_ranker(float c, float lambda) : c_{c}, lambda_{lambda} {}
Where c_
and lambda_
are both private float variables declared in class pl2_ranker
.
Apparently, this constructor is assigning c
to c_
and lambda
to lambda_
, but as a non-cpp programmer, I've never encountered such a syntax before.
Could someone please let me know what this kind of syntax is called and what benefit it provides vs the regular variable assignment inside the function body?