RE: function overloading, parameter list error

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

From: Michael Böhnisch (MichaelBhnisch_at_discussions.microsoft.com)
Date: 08/25/04


Date: Tue, 24 Aug 2004 17:47:02 -0700


"Chris Hawkins" wrote:

> I thought that functions can also differ by whether or not they are const.

Admitted, this a further cue that is used to distinguish overloads.

However, the const in "Type foo( int x, int y ) const" only indicates that
foo does not change it's object memory. The object that is returned by "foo()
const" still is assignable. I assume foo() is indeed Type::foo() ?

> If I remove the const from the foo(double, double) function everything works
> fine. That is, I can call either foo(int, int) const, foo(int, int), or
> foo(double, double). I thought explicitly casting the operands to double's
> or int's should be enough.

This behaviour startles me. To really get down to the core of your problem
further information is needed. What is the signature of the surrounding
method you are calling the assignment? Is it a const member function of the
same class foo() belongs to?

kind regards,
Michael Böhnisch



Relevant Pages

  • Re: Funky function
    ... >> It makes it possible to call this member function on a const object ... >> object may or may not be const). ... int Data; ... in the next line you try to call a function foo on MyData. ...
    (comp.lang.cpp)
  • Re: Need some info on const char **
    ... I don't think the compiler will really like this (it could ... just says 'cast to pointer to const pointer of something ... right and tells me it's using 'int' as the default type. ... promises that foo will not change anything through ca. ...
    (comp.lang.c)
  • Re: help with left-right cdecl rule
    ... This "const int * foo" also makes sense, foo is a pointer to a const ...
    (comp.lang.c)
  • Re: StringBuilder Difficulties
    ... public foobar (int a, String b) { ... declares and initializes an immutable local if no mutable x is within scope, and assigns to the innermost in-scope mutable x otherwise. ... Definite assignment rules would still apply, more-or-less unchanged, ... being a definite assignment violation if no local x existed above "if foo" in that method body, a violation of finalness if a final x existed above "if foo" in the same block, and OK if a mutable x existed above "if foo" in the same scope and was definitely assigned to even if the ...
    (comp.lang.java.programmer)
  • Re: help with left-right cdecl rule
    ... This "const int * foo" also makes sense, foo is a pointer to a const ...
    (comp.lang.c)