[英]Calling another member function from a function in a class template in C++
Let's say I have a class template named myTemplate
with some member variables and two member functions, funcTempA
, and funcTempB
. 假设我有一个名为
myTemplate
的类模板, myTemplate
包含一些成员变量和两个成员函数funcTempA
和funcTempB
。
template <class T>
class myTemplate
{
private:
//member variables
public:
T* funcTempA(T *arg1, T *arg2);
T* funcTempB(T *arg1, T *arg2);
}
funcTempB
calls funcTempA
in its implementation. funcTempB
在其实现中调用funcTempA
。 I just want to know what will be the correct syntax for calling it. 我只想知道调用它的正确语法。
template <class T>
T* funcTempB(T *arg1, T *arg2)
{
//how to call funcTempA here?
}
Just call it directly, such as: 只需直接调用它,例如:
return funcTempA(arg1, arg2);
BTW: The definition of the member function funcTempB
seems wrong, might cause some unexpected errors. 顺便说一句:成员函数
funcTempB
的定义似乎错误,可能会导致一些意外错误。
template <class T>
T* myTemplate<T>::funcTempB(T *arg1, T *arg2)
// ~~~~~~~~~~~~~~~
{
return funcTempA(arg1, arg2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.