I am trying to write a class which no one can derive apart from my classes.
Something like
Code:
class Usable;
// cannot be derived apart from my known classes
class Usable_lock {
friend class Usable;
private:
Usable_lock() {}
Usable_lock(const Usable_lock&) {}
};
class Usable : public virtual Usable_lock {
// ...
public:
Usable();
Usable(char*);
// ...
};
Usable a;
class DD : public Usable { };
DD dd;
// error: DD::DD() cannot access
// Usable_lock::Usable_lock(): private member
I am sure this is possible in C# but I am not sure how. Can you help me in this regard.