C++ a simple count variable makes me trouble

Started by
2 comments, last by brx 12 years, 3 months ago
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 ? ^^
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.
...oh ^^

the return there wasn't my best idea

thank you very much SiCrane !
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.

This topic is closed to new replies.

Advertisement