I'd like to make some basic wrapper classes around simple types in C++. Since you can't just inherit from base types like you should be able to, I'm just using a wrapper class. The problem is, I want to be able to cast directly to that type, since that cast would be totally valid. The compiler just doesn't let you and I can't find a way to tell it that it's ok without running a cast method which kills performance. Is there any way to do this?
Here's what I have for the conversion constructor:
class Integer32
{
public:
Integer32(int value) { this->Value = value; }
int Value;
};
Does the compiler know to skip that and just assign it directly from an int? How do I test this to make sure since it's rather important...