Possible Duplicates:
Variables After the Colon in a Constructor
C++ constructor syntax question (noob)

I have some C++ code here:

class demo 
{
private:
    unsigned char len, *dat;

public:
    demo(unsigned char le = 5, unsigned char default) : len(le) 
    { 
        dat = new char[len];                                      
        for (int i = 0; i <= le; i++)                             
            dat[i] = default;
    }

    void ~demo(void) 
    {                                            
        delete [] *dat;                                           
    }
};

class newdemo : public demo 
{
private:
    int *dat1;

public:
    newdemo(void) : demo(0, 0)
    {
     *dat1 = 0;                                                   
     return 0;                                                    
    }
};

My question is, what are the : len(le) and : demo(0, 0) called?

Is it something to do with inheritance?

6 Answers
6

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *