I want to return an implementation of a class from a function. The function is in a library. I want to prevent the user from destroying the objects I return. How can I achieve this?
EDIT: Example.
Interface to the world:
class Base
{
   public:
      virtual void foo() = 0;
};
Base* GetFoo();
Implementation - Internal:
class Bar : public Base
{
    public:
        void foo() { //Do something}
};
Base* GetFoo()
{
   return new Bar
}
 
     
     
     
     
     
    