Hi,
I do not understand why this does not work:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
template <typename Tint>
class D{
typedef struct XX{
int x;
}XX;
XX* size (Tint z);
public:
D();
Tint get(Tint);
};
template <typename Tint>
D<Tint>::D(){}
template <typename Tint>
XX* D<Tint>::size(Tint z){
XX* h;
Tint j = sizeof(Tint);
h->x = j*z;
return h;
}
template <typename Tint>
Tint D<Tint>::get(Tint){
XX* d;
d=size(10);
return d->x;
}
int main (){
D<int> f;
cout << f.get(10) <<endl;
return 0;
}
error i get is:
Code:
g++ -std=c++0x -o test test.cpp
test.cpp:22:1: error: ‘XX’ does not name a type
how to make it work ???