Skip to main content
GameDev.net gamedev.net
🔒 Locked

Pointers in C++

Started by witchdrash Mar 12, 2003 at 6:04 PM 3 replies 450+ views
Original Post
witchdrash
witchdrash
Now I thought I understood this but I've hit a bit of a wall and the help files aren't well helpful I have a procedure that looks like: void s_loopback_init(TRACK_OBJ *toreceive) { generate_track(toreceive->track,toreceive->driftX,toreceive->driftY, toreceive->size); } This is linking to a procedure void generate_track(TRACK_SECTION *toreceive[],int driftX[], int driftY[], int trackSize) { } Now the problem is when I put a * infront of toreceive->track it errors during compile, how can I move the * to infront of the track variable as it needs to be, I've tried a number of ways and I can't figure it out. Thanks in advance WDA [edited by - witchdrash on March 12, 2003 7:05:06 PM]
Pilatus
Pilatus
first why don''t you just pass on the pointer to the whole object?

try
void s_loopback_init(TRACK_OBJ *toreceive)
{
generate_track(&toreceive->track,&toreceive->driftX,&toreceive->driftY, &toreceive->size);
}
if you want to do it your way o.O
SCRUB
SCRUB

Is TRACK_SECTION *toreceive[] suppose to be a pointer to an array ofTRACK_SECTION pointers ?

You will have to reverence things like this

*toreceinve[0] in essence *(*toreceive))

Note
also your being ambigious with "toreceive"
its confusing whether you mean s_loopback_init
or generate_track

are you trying to do this ?

generate_track(*toreceive->track, ...);

LE SCRUB
witchdrash
witchdrash
Hmm ok sorry yes I was being ambiguous

void s_loopback_init(TRACK_OBJ *toreceive)
{
generate_track(&toreceive->track,toreceive->driftX,toreceive->driftY, toreceive->size);
}

This is linking to a procedure
void generate_track(TRACK_SECTION *receivedtrack[],int driftX[], int driftY[], int trackSize)
{
}

Taking these renamed variables I am receiving the compile error:
e:\Project\temp_server.cpp(190): error C2664: 'generate_track' : cannot convert parameter 1 from 'TRACK_SECTION (*)[1200]' to 'TRACK_SECTION *[]'



What I need is the equivilant of:
generate_track(toreceive->&track.....)

How can I do this, because that also does not compile.

WDA

[edited by - witchdrash on March 12, 2003 10:01:53 PM]
MARS_999
MARS_999
Change this

      
void generate_track(TRACK_SECTION *receivedtrack[],int driftX[], int driftY[], int trackSize)
{
}



to this

void generate_track(TRACK_SECTION receivedtrack[],int driftX[], int driftY[], int trackSize)
{
}


and remove the ampersand symbol(address operator) from your function call.
That should work?

What I need is the equivilant of:
generate_track(toreceive->&track.....)

toreceive->track is a address not a value. toreceive->track[0] is a value

[edited by - Mars_999 on March 12, 2003 10:27:24 PM]

[edited by - Mars_999 on March 12, 2003 10:30:17 PM]

[edited by - Mars_999 on March 12, 2003 10:39:07 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.