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

thanks in advance,

Recommended Answers

All 4 Replies

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.

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

#include <iostream.h>
#include <conio.h>

class SealedBase

#define Sealed private virtual SealedBase 

class Penguin : Sealed

class BigZ : Penguin

void main()
BigZ bigZ;//cannot create obj beacuse penguin is sealed
  cout<<"Sample for selaed":
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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.