I am making an Observer in CPP but I have some problems to make it. I only put two files because the same errors appears in the others. I dispatch my file like this: Event.hh with the declaration of prototypes etc. And Event.cpp with the functions.
Here Event.hh:
#ifndef EVENT_HH
#define EVENT_HH
template <typename Object>
class Event {
public:
Event(Object* obj);
~Event();
Object* getInfo();
private:
Object* _obj;
};
#endif //EVENT_HH
Here the Event.cpp:
#include "Event.hh"
Event::Event(Object* obj) {
this->_obj = obj;
}
Event::~Event() {
delete this->_obj;
}
Event::getInfo() {
return this->_obj;
}
I don't really understand how to use the template and how it works, but I was following a tutorial the only difference is : the developer use one file Event.h with everything in it. I show you the error I have with the compilation:
Event.cpp:3:1: error: invalid use of template-name ‘Event’ without an argument list
Event::Event(Object* obj) {
^~~~~
Event.cpp:3:1: note: class template argument deduction is only available with -std=c++1z or -std=gnu++1z
In file included from Event.cpp:1:0:
Event.hh:6:7: note: ‘template<class Object> class Event’ declared here
class Event {
^~~~~
Event.cpp:7:1: error: invalid use of template-name ‘Event’ without an argument list
Event::~Event() {
^~~~~
Event.cpp:7:1: note: class template argument deduction is only available with -std=c++1z or -std=gnu++1z
In file included from Event.cpp:1:0:
Event.hh:6:7: note: ‘template<class Object> class Event’ declared here
class Event {
^~~~~
Event.cpp:11:1: error: invalid use of template-name ‘Event’ without an argument list
Event::getInfo() {
^~~~~
Event.cpp:11:1: note: class template argument deduction is only available with -std=c++1z or -std=gnu++1z
In file included from Event.cpp:1:0:
Event.hh:6:7: note: ‘template<class Object> class Event’ declared here
class Event {
^~~~~
If you could explain to me what is wrong in my files, I'll appreciate it. Thank you. I have already looked for the errors that I have but I found nothing conclusive.