Hi,
If a function takes a pointer as a parameter as in

void set_owner(Person* p)

how would I write this code? If it wasn't a pointer, I know I'd just write something like

void set_owner(string p)
{
owner = p;
}

Thanks in advance for your help.

Depending on how the variable being passed to the function is declared...

Person guy, gal[10];
   set_owner(&guy);
   set_owner(gal);
   set_owner(&gal[4]);

Depending on how the variable being passed to the function is declared...

Person guy, gal[10];
   set_owner(&guy);
   set_owner(gal);
   set_owner(&gal[4]);

I want to pass it like this.

set_owner(gal);

So then gal is an array of Person s?

You're getting the answer and the question backwards.

So then gal is an array of Person s?

You're getting the answer and the question backwards.

Yeah, I've got it now. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.