C++ - colon after contstructer, what does it mean?
- by waitinforatrain
Hi,
I'd happily google this but don't know what to call it to google it.
I have a piece of 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;
}
};
(It's from a past exam paper and the question is to correct errors in the code so ignore errors!)
My question is, what are the ": len(le) " and " : demo(0, 0)" called? Something to do with inheritence?