jeudi 19 novembre 2020

Is it the correct way to invoke the templatized class from the implementation in C++

I am invoking the templatized class from the actual implementation.

templatized class:

#include <iostream>
#include <list>

template <typename Argone, typename Argtwo>
class CTestImpl
{

public:
    void CTestImpl::handleEvents(Argone f_strID, Argtwo f_obj)
    {
       m_hvar->sendEvents(f_strID, f_obj);
    }
};

Actual implementation:

    string l_strID;
    shared_ptr<CMainImplone> l_hCallObj = nullptr;
    
    shared_ptr<CTestImpl<string, shared_ptr<CMainImplone>>> l_listObj = nullptr;
    l_listObj->handleEvents(l_strID, l_hCallObj);

If i want to invoke from another class like CMainImpltwo with int paramter, can i do like as shown below:

    int l_iD;
    shared_ptr<CMainImpltwo> l_hCallObj = nullptr;
    
    shared_ptr<CTestImpl<int, shared_ptr<CMainImpltwo>>> l_listObj = nullptr;

Is it the correct way to invoke the template class from the implementation like this?

Aucun commentaire:

Enregistrer un commentaire