C++ Crack Code Notes !!!

Constructor initialization lists – C++ provides a way of initializing member variables that allows us to initialize member variables when they are created rather than afterwards. This is done through use of an initialization list.

class Something
{
private:
int m_nValue;
double m_dValue;
int *m_pnValue;

public:
Something() : m_nValue ( 0 ), m_dValue( 0.0 ), m_pnValue( 0 ) // A default constructor
{
}

Something(int nValue, double dValue, int *pnValue) : m_nValue ( nValue ), m_dValue( dValue ), m_pnValue( pnValue ) // A specific constructor
{
}
};

Composition :  

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s