current position:Home>A problem of class template function declaration in C + +

A problem of class template function declaration in C + +

2022-01-27 01:43:24 CSDN Q & A

at night

template <class T>class Base{public:    void show();private:    T number = 1;};template <class T>// Why should we reiterate here template <class T>?void Base<T>::show(){    std::cout << "number The value of is :" << number << std::endl;}

Why declare again before the function definition of the class T Well ?




Refer to the answer 1:

Simply put, grammar rules




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270143229875.html

Random recommended