Jump to content
  • Advertisement
Sign in to follow this  
CoB_ChrizZz

C++ a simple count variable makes me trouble

This topic is 2517 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

http://pastebin.com/tzYQYTDN

this is a Calendar which consists of a base class Time, the derived class Event and a Calandar class that contains a dynamic Event.

the thing is that i wanna try it out in the main function...i create an calendar object, an event and then i enter it to the calendar (as element of the dynamic *buf)

so far everything is good.

next step i wanna print all my events and therefore use a funcetion...but somehow the counter wasn't increased in the enter function as supposed.
I don't know why

Can someone help me with my misery ? ^^

Share this post


Link to post
Share on other sites
Advertisement
In your Calendar::enter() function you bail out of the function if you don't find the event, which means that you can only enter events that are already entered into the calendar.

Share this post


Link to post
Share on other sites
Two remarks:
1) I think it is pretty much accepted that pass by reference means that the caller needs to make sure that it calls the method with a valid object. The
if (&time == NULL)
on references just strikes me odd. If you really want to make sure, I would suggest an assert instead, afterall this can only happen if someone really messes up in the code.
2) Your time comparison methods seem kind of odd to me. You are comparing times based on their address in memory.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!