overloading casting operators

If I have the following code

1
2
3
4
5
6
7
8
9
10
11
12
class A
{
      int m_i;
 public:
      operator int(){return m_i;);
};

VOID MAURHAHRAHRARAR main()
{
     A a;
     PrintThisInt(a); //PrintThisInt(int x); <- lets assume it takes the in and prints it out;)
};



Now I want to change the function to take an argument of type double... do i have to define my own conversion operator double()... or will it be converted implicit because i already did create the operator int() and c++ knows how to convert ints to doubles?...
Last edited on
Suck it and see
I think it will. I remember something about if you made something convertible to bool it could become a int because you could go CLASS -> bool -> int, but I could be wrong.
@guestgulkan: had no chance to try it "yesterday"...

yep, it does work...
Topic archived. No new replies allowed.