You create another class which has the same structure as the given class.
and then create an object of the temporary class and typecast given object
into this new class object, and then access its element.

On Fri, Sep 16, 2011 at 10:04 AM, siddharam suresh
<[email protected]>wrote:

> i saw better solution in stack over flow, but these things violates the
> Memory rules of C++
> Thank you,
> Sid.
>
>
>
> On Thu, Sep 15, 2011 at 6:41 PM, teja bala <[email protected]>wrote:
>
>> @ BHARATH
>>
>> exactly very thx............
>>
>>
>> On Thu, Sep 15, 2011 at 5:22 PM, bharatkumar bagana <
>> [email protected]> wrote:
>>
>>> @teja : r u looking for something like this.......
>>> #include<stdio.h>
>>> #include<stdlib.h>
>>> class Hai
>>> {
>>>  public :
>>>     int* getPointerToPrivate()
>>>     {
>>>         return &i;
>>>     }
>>>     void setI(int j)
>>>     {
>>>         i=j;
>>>     }
>>>  private:
>>>     int i;
>>> };
>>> main()
>>> {
>>>  Hai h;
>>>  h.setI(10);
>>>  int *i=h.getPointerToPrivate();
>>>  printf("%d",*i);
>>>
>>> }
>>>
>>> On Thu, Sep 15, 2011 at 6:41 AM, teja bala <[email protected]>wrote:
>>>
>>>> How to access class private data members with a pointer?
>>>>
>>>> thx in advance?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> **Please do not print this e-mail until urgent requirement. Go Green!!
>>> Save Papers <=> Save Trees
>>> *BharatKumar Bagana*
>>> **http://www.google.com/profiles/bagana.bharatkumar<http://www.google.com/profiles/bagana.bharatkumar>
>>> *
>>> Mobile +91 8056127652*
>>> <[email protected]>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Anup Ghatage

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to