Private destructors

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Private destructors

김동현

Hi,

 

I’m trying to use a class that has private constructor and destructor,

 

For example, creating and destroying an instances of this class is done by other manager not by that class itself.

 

Class A{

Private:

A();

~A();

friend class AManager;

Public:

…..

};

 

Class AManager{

….

Public:

void createA(…);

void destroyA(…)

}

 

I want to bind class A, but It seems that every class must have public destructor to use it with luabind because of garbage collection.

But I don’t want to make it public.

What can I do to solve this kind of problem? I have no idea.

Please help me.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Private destructors

Arvid Norberg-2
Quoting ±èµ¿Çö <[hidden email]>:
> Hi,
> I¡¯m trying to use a class that has private constructor and destructor,
>
> For example, creating and destroying an instances of this class is done by
> other manager not by that class itself.

Of the top of my head, you could try wrapping it in a "smart pointer". Your
smart pointer wouldn't really have to be smart, it could just wrap a pointer
and make sure to never delete the object.

see: http://www.rasterbar.com/products/luabind/docs.html#smart-pointers

--
Arvid Norberg

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user