M
mike
Ok,
IO want to write a class to wrap around another class, to print to the
screen when the vale is changed. So far I have:
template<class T>
class Tracer
{
T data;
public:
Tracer()
{
cout << "New Tracer:" << T() <<"\n";
data = T();
}
Tracer(const T& t)
{
cout << "New Tracer:" << t<<"\n";
data = t;
}
T& operator=(const T& t)
{
cout << "TracerChanged: " << t<<"\n";
data = t;
}
};
allowing me to write:
Tracer<int> a;
Tracer<int> b = 6;
b = 12;
a=4;
but i can't go the other way around:
int e = a; //Error
Now i seem to remeber an explicit operator, and I googled for it this
morning but no luck??
Any thoughts would be apprieciated!
Mike
IO want to write a class to wrap around another class, to print to the
screen when the vale is changed. So far I have:
template<class T>
class Tracer
{
T data;
public:
Tracer()
{
cout << "New Tracer:" << T() <<"\n";
data = T();
}
Tracer(const T& t)
{
cout << "New Tracer:" << t<<"\n";
data = t;
}
T& operator=(const T& t)
{
cout << "TracerChanged: " << t<<"\n";
data = t;
}
};
allowing me to write:
Tracer<int> a;
Tracer<int> b = 6;
b = 12;
a=4;
but i can't go the other way around:
int e = a; //Error
Now i seem to remeber an explicit operator, and I googled for it this
morning but no luck??
Any thoughts would be apprieciated!
Mike