-
Shared Objects in C++
HI
i was writing a piece of code in which i have some problems with shared objects.
I have 2 classes say class A and class B
i want that all objects of class B have a common class A object.
ie one class A object shared by all Class B objects.
I cannot use a static class A object as a member of class B because i need to packge the code as a dll.
Any suggestions on this
Rajan
-
Use a pointer instead of an object. Have each B object contain a pointer to A, and make sure that the pointers in all Bs are bound to the same instance. The Singletone pattern is exactly what you need: http://www.devx.com/DevX/LegacyLink/9472
Danny Kalev
-
a = new A; // (contains class B)
b = new A; // (contains class B)
c = new B;
a.bref = c; // Two references referring to the same reference object.
b.bref = c;
and so on...
EVAC
Similar Threads
-
By Rob Teixeira in forum .NET
Replies: 129
Last Post: 06-06-2002, 05:23 AM
-
By Rob Teixeira in forum .NET
Replies: 15
Last Post: 05-31-2002, 03:30 PM
-
By Patrick Ireland in forum .NET
Replies: 5
Last Post: 05-10-2001, 06:19 PM
-
By Patrick Ireland in forum .NET
Replies: 3
Last Post: 05-07-2001, 03:04 PM
-
By Patrick Ireland in forum .NET
Replies: 0
Last Post: 04-26-2001, 10:01 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|