Why free and realloc seem to include .

Michael via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 3 14:18:22 PDT 2017


On Thursday, 3 August 2017 at 15:29:29 UTC, Adam D. Ruppe wrote:
> On Thursday, 3 August 2017 at 15:18:17 UTC, Michael wrote:
>> I've not seen that either, though I'm not a C++ programmer. 
>> Does using free() on its own not assume access of a global 
>> namespace?
>
> Consider the following:
>
> class Foo {
>    void free(void*);
>
>    void other_method() {
>       free(ptr); // calls the member function
>    }
> }
>
>
> The leading dot in D just ensures it calls the global one 
> instead of a member (if present).

So it could be used without, but you risk conflicts with other 
functions. I got it, thanks to both of you.


More information about the Digitalmars-d-learn mailing list