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();
}; }; };
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();
}; }; };
What makes you think you need a template?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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