I can compile your code with g++ 4.6.3 provided I
  • add #include <iostream>,
  • put the declaration of class Data<T> within namespace jme,
  • change the name of one of the d variables in main(). You can't have two variables with the same name.


2012-09-29 16:02, ArbolOne skrev:

Sorry, I know that this is not a gtkmm code, but I need to plug a template similar to this one in my gtkmm program, and for some reason it will not compile. I just might be that I tired, but I cannot see anything wrong in this code.
template <class T> class Data{
    T data;
    virtual ~Data();
template <class T>
jme::Data<T>::Data() {}

template <class T>
jme::Data<T>::Data(T _data) {
    this->data = ""> }
template <class T>
jme::Data<T>::~Data() {}
using namespace std;
int main() {
    jme::Data<int> d(1); // this does not work
    jme::Data<int> d; // this does not work
    cout << "Hello world!" << endl;
    return 0;
Happiness has many doors, and when one of them closes another opens, yet we spent so much time looking at the one that just closed that we don't see the one that just opened..

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]