Passing along function parameters
Just a note to start, this is cross-posted from gamedev.
I've started theorizing a timer class. I will be using SDL's timer functionality, and basically what I would love to do is have my program start having SDL tick away once I initialize the class, and then let the user start a new timer (not an SDL timer), and end it, allowing me to just compare how many ticks there were from SDL_GetTicks() at the beginning and the end of the user timer.
Here's what I have:
Thing is, as you can see by my comments, I want to create a new type out of my structure with the name passed in the function, but it's set up to use the variables name!
void start(string tstartName);
int end(string tendName);
void timer::start(string tstartName)
// This is where we run into problems
// were actually creating a new timer with the name 'newtName'
// not newtName's variable set above
if(tstartName == NULL)
tstartName.startTime = SDL_GetTicks();
// log error of timer's existance
int timer::end(string tendName)
// Again, we have naming problems here
// pertaining to the variables used for the name
if(tendName != NULL)
Uint32 startTicks = tendName.startTime;
tend.endTime = SDL_GetTicks() - ticks;
// Again, log error of timer's existance
What do I need to do to use the variable passed as the name for the new structure?
Thanks! Hopefully everybody can understand my stupidity :)
PS: For those that aren't familiar with SDL, SDL_GetTicks() returns a 32 bit unsigned integer.