Results 1 to 2 of 2

Thread: compiler is giving an error "Super::Super'

  1. #1
    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

  2. #2
    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

Similar Threads

  1. Replies: 2
    Last Post: 14-08-2012, 12:52 PM
  2. Super Tofu Boy imitated Super Meat Boy
    By Menominee in forum Video Games
    Replies: 5
    Last Post: 04-12-2010, 07:35 AM
  3. Catalyst "Super-User" Problem
    By Daniela007 in forum Operating Systems
    Replies: 4
    Last Post: 24-04-2010, 11:10 PM
  4. Replies: 2
    Last Post: 23-03-2009, 05:44 AM
  5. Super Talent launches new super fast SATA-II SSDs
    By MattyBoy in forum Hardware Peripherals
    Replies: 2
    Last Post: 17-09-2008, 03:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,280,698.49690 seconds with 17 queries