C ++ Error does not match function call method of static template

im trying to call a static method from another class, but when I run it, it returns the following:

PagedArray.cpp:21:37: error: no matching function for call to ‘FileManager::loadPage(int&)’
page = FileManager::loadPage(index);

Here is the code I'm trying to call:

PagedArray.cpp

#include "PagedArray.h"
#include "../Entidades/FileManager.h"


template <typename T>
int* PagedArray<T>::operator[](int index) {

Page<T>* page = nullptr;

for(int i = 0; i < this->pagesQueue->Size(); i++){
    if(index == ( *(this->pagesQueue->get(i)->getDato()) )->getLineaActual()){
        page = *this->pagesQueue->get(i)->getDato();
    }
}

if(page == nullptr){
    page = FileManager::loadPage(index); //This is the problem
}
return page->getInfo()->get(index)->getDato();

}

And this is the FileManager class:

filemanager.h

#include "../Estructuras/Page.h"


class FileManager {

public:

FileManager();

template <typename T>
static Page<T>* loadPage(int index);
};

FileManager.cpp

#include "FileManager.h"

FileManager::FileManager(){}

template <typename T>
Page<T>* FileManager::loadPage(int index) {
    Page<T>* page = nullptr;
    return page ;
}

The body in the loadPage method is just to make a test, so it is not very appropriate, I think. Sorry if I missed something, this is my first time, so if you need something else, leave it below

+4
source share
1 answer

FileManager::loadPageis a function template that has a template parameter that cannot be displayed automatically. Therefore, you must specify it explicitly. eg.

page = FileManager::loadPage<T>(index);
//                          ~~~
+4

Source: https://habr.com/ru/post/1670704/


All Articles