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

Tags: ,

Sponsored Links



compiler is giving an error "Super::Super'

Software Development


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
jasonR's Avatar
Member
 
Join Date: Mar 2008
Posts: 69
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


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
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


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