Calling another member function from a function in a class template in C++

wahab

Let's say I have a class template named myTemplate with some member variables and two member functions, funcTempA, and 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. 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?
}
songyuanyao

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.

template <class T>
T* myTemplate<T>::funcTempB(T *arg1, T *arg2)
// ~~~~~~~~~~~~~~~
{
    return funcTempA(arg1, arg2);
}

LIVE

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

calling method in template class in template member function of another class

From Dev

Calling member function of one class from another

From Dev

C++ templates: Calling member function of derived template class from base class

From Dev

Calling member function of a template class recursively

From Dev

Calling a function from another class?

From Dev

C++ Template class member on a template function

From Dev

Invalid use of non-static member function - Class Member Function Calling Another Class Member Function

From Dev

Calling a class function from within another function

From Dev

Calling function from one class in another class

From Dev

Specialization of member function of a template class in C++

From Dev

C++ Calling set function from another class in file reader

From Dev

Calling a function in the main Form from another Class in C#

From Dev

Calling a function from another class in C#/.NET MVC App

From Dev

Calling template function from inner class

From Dev

Calling main function from another function in C

From Dev

Calling main function from another function in C

From Dev

C++ Pass a member function to another class

From Dev

call member function in another class c++

From Dev

call member function in another class c++

From Dev

Calling a variadic template function with a member function

From Dev

Calling Function from another class swift

From Dev

Python - Calling a function from another class

From Dev

Calling a function from another class in Swift

From Dev

Calling a function from another class? Android

From Dev

Python - Calling a function from another class

From Dev

Calling a member function of a derived class from the base class constructor

From Dev

C++ template explicit specialization - calling existing member function

From Dev

Template std::function as class member function C++

From Dev

Calling a template function from a C file

Related Related

  1. 1

    calling method in template class in template member function of another class

  2. 2

    Calling member function of one class from another

  3. 3

    C++ templates: Calling member function of derived template class from base class

  4. 4

    Calling member function of a template class recursively

  5. 5

    Calling a function from another class?

  6. 6

    C++ Template class member on a template function

  7. 7

    Invalid use of non-static member function - Class Member Function Calling Another Class Member Function

  8. 8

    Calling a class function from within another function

  9. 9

    Calling function from one class in another class

  10. 10

    Specialization of member function of a template class in C++

  11. 11

    C++ Calling set function from another class in file reader

  12. 12

    Calling a function in the main Form from another Class in C#

  13. 13

    Calling a function from another class in C#/.NET MVC App

  14. 14

    Calling template function from inner class

  15. 15

    Calling main function from another function in C

  16. 16

    Calling main function from another function in C

  17. 17

    C++ Pass a member function to another class

  18. 18

    call member function in another class c++

  19. 19

    call member function in another class c++

  20. 20

    Calling a variadic template function with a member function

  21. 21

    Calling Function from another class swift

  22. 22

    Python - Calling a function from another class

  23. 23

    Calling a function from another class in Swift

  24. 24

    Calling a function from another class? Android

  25. 25

    Python - Calling a function from another class

  26. 26

    Calling a member function of a derived class from the base class constructor

  27. 27

    C++ template explicit specialization - calling existing member function

  28. 28

    Template std::function as class member function C++

  29. 29

    Calling a template function from a C file

HotTag

Archive