[英]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 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:
FileManager.h FileManager.h
#include "../Estructuras/Page.h"
class FileManager {
public:
FileManager();
template <typename T>
static Page<T>* loadPage(int index);
};
FileManager.cpp 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. loadPage方法中的主体只是为了进行测试,所以我认为它并不真正相关。 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. FileManager::loadPage
是一个函数模板,它具有一个无法自动推导出的模板参数。 So you have to specify it explicitly. 所以你必须明确指定它。 eg
例如
page = FileManager::loadPage<T>(index);
// ~~~
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.