Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-10-2008
Member
 
Join Date: Oct 2008
Posts: 11
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() {}
};
the compiler is giving an error "Super: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
Reply With Quote
  #2  
Old 25-10-2008
Member
 
Join Date: Mar 2008
Posts: 68
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "compiler is giving an error "Super::Super'"
Thread Thread Starter Forum Replies Last Post
Airtel's Super HD Plus Topup giving 14 HD channels & Zee studio HD at Rs. 5 only for 6 days ronaldobrazil India BroadBand 2 14-08-2012 12:52 PM
Super Tofu Boy imitated Super Meat Boy Menominee Video Games 5 04-12-2010 07:35 AM
Catalyst "Super-User" Problem Daniela007 Operating Systems 4 24-04-2010 11:10 PM
super super hidden directories within $RECYCLE.BIN r0cket Vista Help 2 23-03-2009 05:44 AM
Super Talent launches new super fast SATA-II SSDs MattyBoy Hardware Peripherals 2 17-09-2008 03:01 PM


All times are GMT +5.5. The time now is 11:03 AM.