简体   繁体   中英

C++ Error no matching function for call to static template method

im trying to call a static method from another class but when i run it, it throws this:

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

Here is the code where i try to call it from:

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 class FileManager:

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 the test so its not really relevant i think. Sorry if i missed something, this is my first time here so if you need something else leave it below

FileManager::loadPage is a function template, which has a template parameter that can't be deduced automatically. So you have to specify it explicitly. eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM