hello,
& is the address operator:
void SetPoint(point *pt);
is the proper syntax.
then if you have something like:
int main(void)
{ 
Point *i=new Point();
class1 cls;
cls.SetPoint(&i);
etc.
be sure to free i when your done.

----- Original Message ----- 
From: Jos Timanta Tarigan 
To: [email protected] 
Sent: Friday, December 26, 2008 5:31 PM
Subject: Re: [c-prog] reference object


so i do it like this:

class A{
...
Point * point1;
void setPoint(Point & point1)
}

class B{
...
Point * point1;
void setPoint(Point & point1)
}

and if i change it on class A, it will affect the point in class B?

thanks in advance :)
--- On Fri, 12/26/08, John Gaughan <[email protected]> wrote:

> From: John Gaughan <[email protected]>
> Subject: Re: [c-prog] reference object
> To: [email protected]
> Date: Friday, December 26, 2008, 8:27 PM
> Jos Timanta Tarigan wrote:
> > is it possible to hold just a reference of an object?
> for example if i want two object to keep the address of
> another object, and if one change it, the other one also
> change. What should i keep in each object?
> > 
> 
> You can use either a reference or a pointer.
> 
> MyObject &ref = object;
> MyObject *p = &object;
> 
> References are a little more robust, but less flexible. It
> really 
> depends on what you need to do with it.
> 
> -- 
> John Gaughan



 

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

Reply via email to