435,192 Members | 1,253 Online
Need help? Post your question and get tips & solutions from a community of 435,192 IT Pros & Developers. It's quick & easy.

# help on generic functions

 P: n/a Dear All, Would you please help me to look at this simple case: Assume I have a function to calculate the power of base ^ order. Here base can be of any proper type, and order of type size_t. //! Power with order 0. /*! \param[in] base base. */ template inline Type Power(Type base) { return base * Power(base); } //! Power with order = 0. /*! \param[in] base base. */ template inline Type Power(Type base) { return 1; } I got some compiler error for the second function Power
4 Replies

 P: n/a shuisheng wrote: Assume I have a function to calculate the power of base ^ order. Here base can be of any proper type, and order of type size_t. //! Power with order 0. /*! \param[in] base base. */ template inline Type Power(Type base) { return base * Power(base); } //! Power with order = 0. /*! \param[in] base base. */ template inline Type Power(Type base) { return 1; } I got some compiler error for the second function Power

 P: n/a On 20 Sep 2006 08:35:28 -0700 in comp.lang.c++, "shuisheng" I got some compiler error for the second function Power template class p { public: static inline Type Power(Type base) { return base * p::Power(base); } }; template class p::Power(b); } Sep 20 '06 #3

 P: n/a David Harmon wrote: On 20 Sep 2006 08:35:28 -0700 in comp.lang.c++, "shuisheng"

 P: n/a On 20 Sep 2006 13:18:25 -0700 in comp.lang.c++, "Thomas Tutone" David Harmon wrote: >On 20 Sep 2006 08:35:28 -0700 in comp.lang.c++, "shuisheng"

### This discussion thread is closed

Replies have been disabled for this discussion.