T
Tao Wang
Hi,
I have a class Data as following
class Data{
....
};
I know if I want to cast it to int implicitly I should write like
following:
class Data{
....
public:
operator int() {...};
};
So, I can use the class like,
Data d(1234);
int a = d;
However, what I really want is that user of class Data have explicitly
cast it to int.
that is, user should write the code like:
int a = (int) d;
other than:
int a = d;
How can I make the cast to int explicitly only?
Thanks.
Tao Wang
I have a class Data as following
class Data{
....
};
I know if I want to cast it to int implicitly I should write like
following:
class Data{
....
public:
operator int() {...};
};
So, I can use the class like,
Data d(1234);
int a = d;
However, what I really want is that user of class Data have explicitly
cast it to int.
that is, user should write the code like:
int a = (int) d;
other than:
int a = d;
How can I make the cast to int explicitly only?
Thanks.
Tao Wang