I would like to modify and clarify my point here
 
I have a class in which constructor I have declared a member variable as 0. Now 
I am using a shared pointer to access object created in heap. So incase if we 
create another instance of the class will there only be one instance of the 
class but two shared pointers or two instances of class.
 
My interest is the class constructor is initializing the member variable to 0. 
Now before the second instance is created that member variable is incremented. 
SO when the second call  is made will the first instance see the value of x as 
0?
 
Please confirm



________________________________
From: Satya Prasad <[email protected]>
To: [email protected]
Sent: Saturday, March 21, 2009 10:30:10 AM
Subject: [c-prog] Re: Shaerd pointer


For example:
 
        class A
        {
                public:
                virtual ~A()
                {
                }
                  int x;
        };
        typedef boost::shared_ ptr<A> APtr;
        APtr getA();
 
        APtr getA()         
        {
                return APtr(new A());
        }
        A::A()
        {
                x = 0;
        }

When ever I call APtr getA()   will every instance of A will see x as 0?
 
Regards,
Prakash

____________ _________ _________ __
From: Satya Prasad <satya_prakash_ pra...@yahoo. com>
To: c-p...@yahoogroups. com
Sent: Saturday, March 21, 2009 10:15:19 AM
Subject: Shaerd pointer

Hi All,
 
I would like to know that incase of shared pointer if one reference modifies a 
value of an object will the other one will the modified values? How can we 
ensure that two instance of shared pointers if change object values, each of 
them retains its original? Is that possible using shared pointer. 
 
Regards,
Prakash

[Non-text portions of this message have been removed]





      

[Non-text portions of this message have been removed]

Reply via email to