A
Amit
please see the following lines of codes :
class ABase; // i want to make it non-derivable
class Super
{
private:
Super () {};
friend class ABase;
};
class ABase : virtual public Super
{
private:
int i;
public:
ABase () {}
void seti (int j) { i=j; }
int geti () { return i; }
};
void main()
{
ABase a;
a.seti(100);
cout<<endl<<a.geti()<<endl;
}
here if we try to derive a class from ABase ;
class BDer : public ABase
{
public:
BDer() {}
};
the compiler is giving an error "Super::Super' : cannot access private
member declared in class 'Super'".
But if we remove the "virtual" in class ABase : virtual public Super,
then we can derive from ABase. How the keyword "virtual" making ABase
non-derivable??? Is there any workaround for this problem???
I hope the problem is clear to you.
Thanks,
Amit Kumar.
class ABase; // i want to make it non-derivable
class Super
{
private:
Super () {};
friend class ABase;
};
class ABase : virtual public Super
{
private:
int i;
public:
ABase () {}
void seti (int j) { i=j; }
int geti () { return i; }
};
void main()
{
ABase a;
a.seti(100);
cout<<endl<<a.geti()<<endl;
}
here if we try to derive a class from ABase ;
class BDer : public ABase
{
public:
BDer() {}
};
the compiler is giving an error "Super::Super' : cannot access private
member declared in class 'Super'".
But if we remove the "virtual" in class ABase : virtual public Super,
then we can derive from ABase. How the keyword "virtual" making ABase
non-derivable??? Is there any workaround for this problem???
I hope the problem is clear to you.
Thanks,
Amit Kumar.