devxlogo

Initializing Class Members

Initializing Class Members

The following code demonstrates how to initialize class members in the initialiser list for more efficiency:

class A{int a;char b;float c;public:    A();};A::A():a(0),b(0),c(0){}is more efficient thanA::A(){    a = 0;    b = 0;    c = 0;}

devx-admin

Share the Post: