繁体   English   中英

C ++错误没有用于调用静态模板方法的匹配函数

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

我试图从另一个类调用一个静态方法但是当我运行它时,它抛出这个:

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

这是我尝试从中调用它的代码:

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();

}

这是类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 ;
}

loadPage方法中的主体只是为了进行测试,所以我认为它并不真正相关。 对不起,如果我错过了什么,这是我第一次来这里,所以如果你需要别的东西,请留下

FileManager::loadPage是一个函数模板,它具有一个无法自动推导出的模板参数。 所以你必须明确指定它。 例如

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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