In C++0x you have a simple solution. I don’t know whether it is implemented in MSVC10 however.
template <typename T>
struct base
{
private:
~base() {}
friend T;
};
// Doesn't compile (base class destructor is private)
struct foo : base<bar> { ... };
More Related Contents:
- What is the curiously recurring template pattern (CRTP)?
- C++ static polymorphism (CRTP) and using typedefs from derived classes
- CRTP to avoid dynamic polymorphism
- operator= and functions that are not inherited in C++?
- Practical Uses for the “Curiously Recurring Template Pattern”
- invalid use of incomplete type
- CRTP — accessing incomplete type members
- Invalid covariant type with CRTP clonable class
- C++ Looping / Array
- Is there a way to create a c++ gui game without win32 api, openGL, direct X and stuff? [closed]
- Why is sizeof giving incorrect number of bytes in C++?
- Where to use empty character constant ” in C++? [closed]
- Changing the object a pointer points to in c++
- Address of an array
- What does the standard library guarantee about self move assignment?
- Is floating point addition commutative in C++?
- std::optional specialization for reference types
- Implementing Qt project through CMake
- casting via void* instead of using reinterpret_cast [duplicate]
- Multiple Inheritance from two derived classes
- Do built-in types have move semantics?
- Variadic function template with pack expansion not in last parameter
- Portable way of setting std::thread priority in C++11
- Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?
- Why can’t I initialize a reference in an initializer list with uniform initialization?
- C++ generating random numbers
- array of pointers as function parameter
- How to create a vector of user defined size but with no predefined values?
- How to tell if a lib was compiled with /mt or /md?
- How do I include the string header?