Operator overloading, well member function overload in general.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi:

So I'm trying to overload an operator. I have the following two
operators:

virtual T operator()(float x, float y, float z) const;
virtual T operator()(int x, int y, int z) const;

If I call it with foo(1.0f, 1.0f, 1.0f) I get an "overloads have
similar conversions" error. Even if I explicitly cast with
foo((float)1.0f, (float)1.0f, (float)1.0f) it's still ambiguous to VC++
..Net 2003. But if I declare it:

virtual T operator()(float &x, float &y, float &z) const;

It all works fine. As I understand C++, the first set of declarations
should work. Why would that be ambiguous? Am I wrong about this or is
it a bug in VC++?

David

.



Relevant Pages

  • Re: A question on variable defination
    ... nmriopen(char *const filename, const int np1, const float step1, ...
    (comp.lang.c)
  • Re: Question on Data Type Declarations
    ... When we declare variables like ... example) a letter 'a' in an int, ... Aren't the names 'float', 'int', 'char' and so forth simply there to ... declaring "float x;" does much more than just telling the compiler ...
    (comp.lang.c)
  • Re: graphics in c
    ... least one problem which is not about system-specific extensions. ... Better declare it as local to mainand pass it to the function. ... float dx,dy; ... void slopelessthanone(int x1, int y1, int x2) ...
    (comp.lang.c)
  • Re: to const or not to const
    ... Does it help to declare integer function arguments as const? ... const int func ... The parameter 'const float *f' means that what the ...
    (comp.lang.c)
  • Re: functions arguments
    ... ptr to int** ptr during a series of calls and back again. ... I have to write float but I want it to be flexible here. ... typedef enum Type Type; ... void SetToFive(Type const t,void *const p) ...
    (comp.lang.c)