Is there any way to make a class that can not be inherit in C++ like java. If yes How to do that?
Asked
Active
Viewed 75 times
2 Answers
3
Try to read this article might be helpful.
http://www.codeproject.com/Articles/4444/A-non-inheritable-class
From the article:
template <typename T>
class MakeFinal
{
private:
~MakeFinal() { };
friend T;
};
Inherit from it:
class FinalClass : virtual public MakeFinal<FinalClass>
{ }

Blacktempel
- 3,935
- 3
- 29
- 53

bhadram
- 714
- 2
- 8
- 22