R
Rahul
Hi Everyone,
I have the following code and the compiler complains that there isn't
any default constructor available,
class C
{
private:
C()
{
printf("in private constructor of C\n");
}
};
class E : public C
{
}
E obj; // compile time error saying no default constructor
available in E.
However, it works fine if i change the constructor C() from private to
public access specification. I'm wondering why this is so?
I was thinking that default constructor is needed only in these
following cases,
1) a explicit constructor is provided
2) a custom constructor accepting parameters is provided
but i seem to be missing some other cases, can anyone point out that?
Thanks in advance!!!
I have the following code and the compiler complains that there isn't
any default constructor available,
class C
{
private:
C()
{
printf("in private constructor of C\n");
}
};
class E : public C
{
}
E obj; // compile time error saying no default constructor
available in E.
However, it works fine if i change the constructor C() from private to
public access specification. I'm wondering why this is so?
I was thinking that default constructor is needed only in these
following cases,
1) a explicit constructor is provided
2) a custom constructor accepting parameters is provided
but i seem to be missing some other cases, can anyone point out that?
Thanks in advance!!!