Hi, I've one problem. I want to disallow to call destructor on object which I want always have in QSharedPointer. I was trying something as this:
Qt Code:
  1. class X
  2. {
  3. protected:
  4. ~X() {};
  5.  
  6. class Deleter;
  7. friend class Deleter;
  8.  
  9. class Deleter
  10. {
  11. void operator()(X* p) { delete p; }
  12. };
  13.  
  14. public:
  15. QSharedPointer<X> create()
  16. {
  17. QSharedPointer<X> px = QSharedPointer<X>(new X(), X::Deleter());
  18. return px;
  19. }
  20. };
To copy to clipboard, switch view to plain text mode 

But this code is not compilable:
Error 1 error C2248: 'X::~X' : cannot access protected member declared in class 'X' c:\qt\4.6.2\src\corelib\tools\qsharedpointer_impl. h 391

It's probably because what QSharedPointer is implemented. But is there any way how to disallow to anybody to destrouy object using standard c++ pointer? I thing it will be much more secure and clearer.

Thanks.