Link to home
Start Free TrialLog in
Avatar of rmvprasad
rmvprasad

asked on

Templates

I am not understanding the concept of templates. In my program I have a customer class truck class and contract class. I am not getting an idea how to templates for this. take the class roughly as below
class customer                class truck                                                    class contract
{                                   {                                                                  {
private:                           private:                                                        private:
  char* Name;                    enum truck{ford, toyota, Benz};                     int No_of_months;
  int age;                            int truc_milage;                                            DATE start_date;
public:                            public:                                                          public:  
 getage();                          get_trucktype();                                            get_contractdate();  
 setage();                          get_milage();                                                get_No_ofmonths();
};                                  };                                                                 };
Avatar of Axter
Axter
Flag of United States of America image

What makes you think you need a template?
ASKER CERTIFIED SOLUTION
Avatar of Sys_Prog
Sys_Prog
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmvprasad
rmvprasad

ASKER

I am told to do so. My doubt is in this design of multiclasses should I write a template for each class or can it be done for a group of classes. If so how. If not then how to decide to which classes templates have to be applied. Please explain that.
It can and should be done for group of classes with the same amount of functions and functionality.
If you have 2 classes and both of them has 2 functions that return integer and string then you can write
a TEMPLATE class for them.

Regards,
  Tomas Helgi