Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gf11speed

Somewhat Simple Question

This topic is 5933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is wrong with this code? For some reason, the variables that I set in the Check() function are not set after the function ends. So I lose all my dad after the function returns. if(......) { RaceHorse.BestTime8Furlong.Check(RACE_CLOCK) } Inside the ''BestTime8Furlong'' structure, the Check() looks like this: void Check(RACE_CLOCK race_clock) { iBestTimeMinutes = race_clock.BestTimeMinutes; iBestTimeSeconds = race_clock.BestTimeSeconds; fBestTimeMilliseconds = race_clock.BestTimeMilliseconds; } What am I doing wrong? Thanks. *====================* http://www.syntasoft.com *=======================*

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try this:

void Check(RACE_CLOCK &race_clock)
{
...
}

Share this post


Link to post
Share on other sites
But I''m not setting RACE_CLOCK, I''m setting the other variables. So would that matter?

*====================*
http://www.syntasoft.com
*=======================*

Share this post


Link to post
Share on other sites
Need more info I think, if the rest of the code looks like the way I would have made it that little tidbit should work. So I think your problem doesn''t lie in that code.

Is iBestTimeMinutes a member of BestTime8Furlong?

~Vendayan

Share this post


Link to post
Share on other sites
quote:
Original post by Gf11speed
What is wrong with this code?

It''s not adequate for diagnosing your actual problem. Are you able to put together a small program that exhibits the problem?
quote:

So I lose all my dad after the function returns.

That must be terrible. When was the last time you saw him?


[C++ FAQ Lite | ACCU | Boost | Stroustrup on Learning C++]

Share this post


Link to post
Share on other sites
^_^ It looks pretty screwed to me.
presumably RACE_CLOCK is a type, judging by the function definition, so why is he passing a type to the function? I suggest the poster gets himself a book on learning C/C++.

____________________________________________________________
www.elf-stone.com

Share this post


Link to post
Share on other sites
I forgot to mention that the variables:
iBestTimeMinutes
iBestTimeSeconds
fBestTimeMilliseconds

are all members of the ''BestTime8Furlong'' structure.


I am calling the BestTime8Furlong.Check() function to change local variables to the ''BestTime8Furlong'' function.

*====================*
http://www.syntasoft.com
*=======================*

Share this post


Link to post
Share on other sites
1. Pass the object by address or reference
2. Pass the object, not the type, as you appear to be doing.

Passing by address (note also, the OBJECT is passed, not the TYPE)

    
//somewhere in the code

RACE_CLOCK rc;

if(......)
{
RaceHorse.BestTime8Furlong.Check(&rc)
}


void Check(RACE_CLOCK * race_clock)
{
iBestTimeMinutes = race_clock.BestTimeMinutes;
iBestTimeSeconds = race_clock.BestTimeSeconds;
fBestTimeMilliseconds = race_clock.BestTimeMilliseconds;
}



3. Buy a book and learn C++



____________________________________________________________
www.elf-stone.com

[edited by - benjamin bunny on April 18, 2002 7:13:58 PM]

Share this post


Link to post
Share on other sites
benjamin bunny:

1) Thanks for the help
2) I tried that already and it didn''t work
3) Learn to stop being an asshole

*====================*
http://www.syntasoft.com
*=======================*

Share this post


Link to post
Share on other sites
I thought it was more polite than just RTFM.

By the way, passing the type will not work. I don't know what exactly you're doing wrong, but passing the type is just incorrect. You should either pass a pointer or a reference to the object.
____________________________________________________________
www.elf-stone.com

[edited by - benjamin bunny on April 19, 2002 6:54:10 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!