Hi,

Can anybody explain me how to create a sealed class on c++.

thanks in advance,
kedar

Re: Sealed class in c++ 80 80
Re: Sealed class in c++ 80 80

A start?

i know this solution using private constructor.

So, the user has to call the static method to create the new object. Is there anything better than this.

Re: Sealed class in c++ 80 80

>Is there anything better than this.
No, not really. The question you should be asking yourself is why do you need this feature in the first place? Clicky.

Re: Sealed class in c++ 80 80
#include <iostream.h>
#include <conio.h>

class SealedBase
{
protected:
    SealedBase()
    {
    }
};

#define Sealed private virtual SealedBase 

class Penguin : Sealed
{
};

class BigZ : Penguin
{
};

void main()
 {
BigZ bigZ;//cannot create obj beacuse penguin is sealed
  clrscr();
  cout<<"Sample for selaed":
  getch();
  }
commented: 6 year bump, no code tags, void main rubbish for TurboC -4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.