Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax of out-of-class definition of a template member function of a template class

Tags:

c++

syntax

template<typename A, typename B>
class mindF_ck
{
    template<typename C>
    inline bool ouch(C & c_in);    
};

How do I define the signature for ouch out-of-class ? I send a query to my brain but it keeps coming up blank ;)

like image 814
Hassan Syed Avatar asked May 05 '11 09:05

Hassan Syed


People also ask

What is the correct syntax of defining function template template functions?

Defining a Function TemplateA function template starts with the keyword template followed by template parameter(s) inside <> which is followed by the function definition. In the above code, T is a template argument that accepts different data types ( int , float , etc.), and typename is a keyword.

How would you define member function outside the class template?

Member functions of class templates (C++ only) You may define a template member function outside of its class template definition. The overloaded addition operator has been defined outside of class X . The statement a + 'z' is equivalent to a. operator+('z') .

What is the syntax of template class?

1. What is the syntax of class template? Explanation: Syntax involves template keyword followed by list of parameters in angular brackets and then class declaration.

Which is correct syntax to define template?

What is the correct syntax of defining function template/template functions? Explanation: Starts with keyword template and then <class VAR>, then use VAR as type anywhere in the function below.


2 Answers

template<typename A, typename B>
template<typename C>
bool mindf_uck<A,B>::ouch(C & c_in) {
}
like image 131
Gunther Piez Avatar answered Oct 13 '22 10:10

Gunther Piez


template <typename A, typename B>
  template <typename C>
bool mindf_ck<A, B>::ouch(C& c_in) {
    // ... code ...
}
like image 30
Lstor Avatar answered Oct 13 '22 10:10

Lstor