codice:
#include <iostream>
#include "StateManager.h"
#include "Entity.h"
#include "Menu.h"
#include "AI_followTarget.h"
using namespace std;
int main() {
StateManager *mainStateManager = new StateManager();
mainStateManager->changeState<Menu>();
while (1){
//mainStateManager->update();
}
system("pause");
return 0;
}
Ragazzi come mai qui:
codice:
mainStateManager->changeState<Menu>();
mi da questo errore:
codice:
error LNK2019: riferimento al simbolo esterno "public: void __thiscall StateManager::changeState<class Menu>(void)" (??$changeState@VMenu@@@StateManager@@QAEXXZ) non risolto nella funzione _main
fatal error LNK1120: 1 esterni non risolti
questi sono i file StateManager:
StateManager.h:
codice:
#pragma once
#include "State.h"
class StateManager {
private:
State *currentState;
public:
StateManager();
template <class T> void changeState();
void update();
};
StateManager.cpp
codice:
#include "StateManager.h"
#include <stdlib.h>
StateManager::StateManager() {
}
template<class T>
void StateManager::changeState()
{
if (this->currentState != NULL) this->currentState->destroy();
this->currentState = new T();
this->currentState->manager = this;
this->currentState->init();
}
void StateManager::update() {
//if (this->currentState != NULL){}
}