Can someone please explain this MyClass(int a) : var(a) { } | SoloLearn: Learn to code for FREE!

+2

Can someone please explain this MyClass(int a) : var(a) { }

6/24/2019 6:37:13 PM

Lehlohonolo Motsei

2 Answers

New Answer

+3

Lehlohonolo Motsei member variable "var" of type int is initialized with the value of a in the constructor using member initialization list.

+1

MyClass(into a){var {a};} initializes var twice, in list and block. So we can say that using list in this case is more efficient