Reputation: 73
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
Upvotes: 4
Views: 690
Reputation: 172924
FileManager::loadPage
is a function template, which has a template parameter that can't be deduced automatically. So you have to specify it explicitly. e.g.
page = FileManager::loadPage<T>(index);
// ~~~
Upvotes: 4