chiedo scusa, ma ho postato il codice errato e in modo incompleto. nel codice corretto
il template viene istanziato con il paramentro reale int*.
il construttore prende come parametro un parametro di tipo T.
codice:
#include <cstdlib>
#include <iostream>
using namespace std;
template<class T>
class Int{
public:
T i;
Int( T value );
T getValue();
~Int();
bool operator==( const Int& right );
};
template<class T>
Int<T>::Int( T value ){
i = value;
}
template<class T>
Int<T>::~Int(){
i = NULL;
}
template<class T>
T Int<T>::getValue(){
return i;
}
template<class T>
bool Int<T>::operator==( const Int<T>& right ){
return *i == *right.getValue();
}
int main(){
int i1 = 15;
int i2 = 15;
int* p1 = &i1;
int* p2 = &i2;
Int<int*>* I1 = new Int<int*>( p1 );
Int<int*>* I2 = new Int<int*>( p2 );
if( *I1 == *I2 ){
cout << "okk!!!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}