Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C
Expertise: Beginner
Feb 23, 2004

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 than
A::A()
{
    a = 0;
    b = 0;
    c = 0;
}
Rahul Gupta
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap