Problems with function names in D

Say I have a Foo class with a member dashboard (). I also have a completely unrelated function, which is also called bar ().

class Foo { /* ... */ void bar() { /* ... */ } } void bar() { /* ... */ } 

It seems that any call to bar () from within Foo defaults to a member function.

How to call non-member function from inside Foo?

+6
source share
1 answer

Like this:

 .bar(); 

Lead . will force the compiler to see the scope at the module level.

You can also use the full name: module_name.bar() , where module_name is the name of the module (the default file name without the extension .d ).

+13
source

Source: https://habr.com/ru/post/983657/


All Articles