N
Neo
Hi Friends,
I want to create a single instance of my class and use it through
out my program.
Simple solution is, I can make a static method and invoke it by
different callers. So first caller will be responsible for creating
the object. To make this behavior thread safe I will be protecting the
object creation call in a critical section.
Now another idea I have is of putting dynamic allocation in global
space instead of a static method like
*point_to_object = new class_name(); // this will be in global space
I saw that this works well. I can destroy this object during the exit
of my program. I am interested in knowing that are will there be any
issues related to run time libraries, platform specific etc?
I want to create a single instance of my class and use it through
out my program.
Simple solution is, I can make a static method and invoke it by
different callers. So first caller will be responsible for creating
the object. To make this behavior thread safe I will be protecting the
object creation call in a critical section.
Now another idea I have is of putting dynamic allocation in global
space instead of a static method like
*point_to_object = new class_name(); // this will be in global space
I saw that this works well. I can destroy this object during the exit
of my program. I am interested in knowing that are will there be any
issues related to run time libraries, platform specific etc?