My code is as follows
template <typename T>
class name
{
public:
name() : h_(0){}
template <typename U>
operator name<U>()
{
name<U> u;
u.h_ = h_;
return u;
}
private:
int h_;
};
int main(void)
{
name<int> a;
name<double> b = a;
return 0;
}
The error that I get is int name<double>::h_ is private
. How to fix the error?