Possible Duplicate:
Making a template parameter a friend?
C++ Faq 23.11 How can I set up my class so it won't be inherited from? lists the following code:
class Fred;
class FredBase {
 private:
   friend class Fred;
   FredBase() { }
};
class Fred : private virtual FredBase {
public:
   ...
};
I tried to make a generic template for the same.
#include <stdio.h>
template<typename MAKE_ME_NONINHERITABLE >
class NonInheritable{
private:
  NonInheritable(){
  }
  friend  MAKE_ME_NONINHERITABLE;  //<--- error here 
};
This give me an error:
xxx.cpp:11: error: a class-key must be used when declaring a friend
So I tried:
template<typename  MAKE_ME_NONINHERITABLE >
class NonInheritable{
private:
  NonInheritable(){
  }
  friend class MAKE_ME_NONINHERITABLE; //<--- error here 
};
class A : virtual public NonInheritable<A>{
};
And I get this error:
xxx.cpp:11: error: using typedef-name `MAKE_ME_NONINHERITABLE' after `class'
Is there a way to make this work?