Languages

Menu
Sites
Language
Making a SO file multiton

I'm trying to create multiple instances of a library so file but when I try to create 2 objects it turns out to be the same.

 

So is it possible to create multiple objects of a class defined in so file. If yes what could be the possible reason for the above.

Responses

12 Replies
Derek Forbes

Hello, yes, it is possible to create multiple objects of a class defined in a shared object (so) file. The issue you are facing may be due to a misunderstanding or a mistake in your code

victoria emmy

The design of the class to ensure that only one instance is created and make a provision to globally access the instance. 

Kirk McBride

Yes, it is possible to create multiple objects of a class defined in a shared object (so) file. Each object will have its own separate instance and memory space. If you are experiencing a situation where creating multiple objects of a class from an so file results in them being the same, it could be incorrect usage of the class or its initialization.Make sure you are correctly instantiating the class and calling its constructor to create new objects. Verify that you are not accidentally reusing the same object or storing references to the same object in multiple variables.

Adriana Wills

As far as I know creating multiple (SO) file is possible.
 

Nadia Eira

To the best of my knowledge, it is possible to create multiple (SO) files.

Thomas Rodriquez

The class in the so file may be implemented as a singleton, which is designed to have only one instance throughout the lifetime of the program. In this case, no matter how many objects you create, they will all refer to the same instance. Check the implementation of the class to see if it follows the singleton pattern.