Я совершенно не знаком с классами шаблонов. Я создал один, но у меня нет доступа к переменной public класса в методе.C++ template class - переменная класса в методе недоступна
Программа рушится. Смотреть в режиме отладки: нет члена с именем q. -> CRASH
Класс:
#ifndef SIMULATOR_H
#define SIMULATOR_H
#include<queue>
#include<Event.h>
#include <functional>
#include <vector>
#include <iostream>
using namespace std;
template<class T>
class Simulator
{
public:
std::priority_queue<Event<T>*> q;
int i;
Simulator()
{
}
virtual ~Simulator()
{
//dtor
}
void addEvent(Event<T> *e)
{
i = 5; //Watch in debug mode: There is no member named i. --> CRASH
this->q.push(e); //Watch in debug mode: There is no member named q. --> CRASH
}
};
#endif // SIMULATOR_H
main.cpp
Simulator<int> *simulator;
simulator->addEvent(event);
Где код для вашего класса Event? Где в главном объявлен объект события? –