Hi, Google Template classes in c++ (or) generic classes in c++ you will get lots of example
Regards, S.C.Harish Associate Software Engineer, Cordys R&D <http://www.cordys.com/>, Hyderabad On Mon, Sep 5, 2011 at 5:11 PM, kARTHIK R <[email protected]> wrote: > For sending the type, you dont have to denote it explicitly. Use templates. > > template<typename T> void func (T *a) { > // business logic > > } > > > I dont think you can pass operators directly. > For arithmetic operators, you could use something like this : [refer some > site for exact syntax] > > template<typename T1, typename T2> void functioname ( T1 *argument, T2 > operation) { > > T1 result = operation(argument[1] , argument[2]); > > } > > > > main() { > > int a[]={1,2,3,4,5}; > functioname(a, std::multiplier<int>()); > > > } > > Karthik R, > R&D Engineer, > Tejas Networks. > > > > On Mon, Sep 5, 2011 at 11:52 AM, punnu <[email protected]> wrote: > >> I have to pass a general array in a function whose type will also be >> passed and also a function pointer for ">" or "<". >> e.g. >> >> void function(type , type array, "pointer for > or <") >> >> how will you write it in C? >> >> Thanxx in Advance >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
