4
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by Karty619
0

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.

0

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

-1
#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();
  }

Edited by Narue: Added code tags

Votes + Comments
6 year bump, no code tags, void main rubbish for TurboC
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.