Hi,
I have some troubles with conversion operators !
I have 2 classes which handle colors, one provided by the .NET framework (System::Drawing::Color) and the other by the DirectX SDK (D3DCOLORVALUE) They are basically the same, they juste store the RGB values and an alpha. The difference is one is using floats between 0 and 1 and the other ints between 0 and 255.
So I'd like to create operators to implicitely converts one class to the other and vice versa. But I really don't understand how to do that ...
I found a page in the MSDN saying that the correct way to define conversion operators is :
System::Drawing::Color op_Implicit(D3DCOLORVALUE value);
And when I use this syntax, it compiles fine. But when I try to use it by writing something like :
D3DCOLOR value src;
System::Drawing::Color dest;
dest = src;
The compiler tells me that no user-defined-conversion operator is available ...
So I don't know what to do and google is not of much help on this :s Anybody has and idea ??
PS: I know how to create conversion functions as member of classes, but in my case, I don't have access to System::Drawing::Color nore D3DCOLORVALUE so I need to create a "global" conversion operator.