Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
don't understand this code..
11-13-2008, 12:24 PM,
don't understand this code..
Hi all (especially joe :wink: )
I'm looking your new code...
example cartire.h....

what means the T datatype?
template <typename>
i feel hard understand this...
thanks in advance!

11-13-2008, 12:45 PM,
I guess that it means that you can use it universally.
On objectcreation you specify what type you want to use e.g.
CARTYRE <int> tire;
And then all occurrences of T will be replaced by the specified type.

Others will probably explain it better Smile
11-14-2008, 09:09 AM,
thanks, so in some part of the code is there a definition of T used by a double for example
11-16-2008, 05:06 PM,
Here's a pretty good introduction to templates (specifically see the section on Class Templates):

In the car.h file you'll see CARDYNAMICS <double> dynamics, which means that for all of the car classes "double" gets substituted for T. I did it this way in case I wanted to try using a 32-bit float instead of a 64-bit double.
11-17-2008, 03:55 AM,
thanks joe! :wink:

Forum Jump:

Users browsing this thread: 1 Guest(s)