View Single Post
  #1 (permalink)  
Old 10-13-2011, 09:07 PM
Chatsiri Ratana
Guest
 
Posts: n/a
Default How to learning about generic programming?

Hello all,
I have questions about the Generic Programming which using with
template parameter in order to send parameter into once class. I
actually write class for storing a member function of class cause it
should be properties that using with other class. Why we using
template for classes? If I needed using generic programming, How i
should learn about it's? I write example code by generic programming
with a car class.
template <typename T>
class car{
public:
bool set_gear(T&)
{
gear_value_ = T.gear_value();
}
private:
int gear_value_;
};
How I should send value or instance of classes to a template parameter
of class car? I thinking apply template parameter concepts of generic
programming for work.

Best Regards,
Chatsiri Rattana


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Reply With Quote