// Prevent inheritance from a class
#define DECLARE_FINALIZE(C_)\
class C_;\
class Finalize_##C_{\
friend class C_;\
private:\
Finalize_##C_() {}\
}
#define FINALIZE(C_) virtual Finalize_##C_
// Test finalizing
DECLARE_FINALIZE(Base);
class Base: FINALIZE(Base) { // This finalizes 'Base'
};
class Derived : public Base{
};
Base b_;
Derived d_; // error: cannot access private constructor of 'Finalize_Base'
Subscribe to:
Post Comments (Atom)

1 comment:
Dear, plz write the blog for unix,bcoz I want to know about unix.
Post a Comment