RE: Why overloading is not allowed for CV qualifier.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mustafa,

> Why CV qualifier cannot distinguish two functions for overloading ?

The const is an implementation detail.  It is not distinguishing for pass-by-value.

You can do this:

// Header
extern void Foo(int);

// Source implementation
void Foo(int const inValue)
{
  // ...
}

And that Foo will have the correct name mangling to implement the declaration in the header.

That is NOT the situation for pass-by-reference or pass-by-pointer.

These two are different:
extern void Foo(int*);
extern void Foo(int const*);

While the pointer itself (which is pass-by-value (i.e., the pointer value)... ugh, don't think about it too hard or you'll hurt your brain) cannot use const to distinguish:
extern void Foo(int*);
extern void Foo(int* const); // Not a distinguishing overload.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux