|
| |||||||||
| Tags: compiler, supersuper |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| compiler is giving an error "Super::Super'
please see the following lines of codes : class ABase; // i want to make it non-derivable Code: 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() {}
}; uper' : 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 ? Thanks |
|
#2
| ||||
| ||||
| Re: compiler is giving an error "Super::Super'
Well, making a class non-derivable is really simple. You can find the answer in FAQ. However, having a generic solution for this problem is better, but harder to implement. I was investigating this problem a long time ago. Basically, a mix of template friends, access levels and virtual inheritance does this job. The article about my solution can be found here |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "compiler is giving an error "Super::Super'" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Super Tofu Boy imitated Super Meat Boy | Menominee | Video Games | 5 | 04-12-2010 07:35 AM |
| Super Meat Boy "input not supported" | Agamjot | Video Games | 4 | 02-12-2010 03:25 PM |
| Catalyst "Super-User" Problem | Daniela007 | Operating Systems | 4 | 25-04-2010 12:10 AM |
| super super hidden directories within $RECYCLE.BIN | r0cket | Vista Help | 2 | 23-03-2009 06:44 AM |
| Super Talent launches new super fast SATA-II SSDs | MattyBoy | Hardware Peripherals | 2 | 17-09-2008 04:01 PM |