On Sunday, 23 March 2014 at 21:48:33 UTC, MarisaLovesUsAll wrote:
Hi! I didn't find how to implement functions outside the class,
like in C++.
C++:
class MyClass
{
void myFunc();
};
void MyClass::myFunc() { ... }
Is it possible to do this in D ?
Sorry for my bad English.
Regards,
Alexey
On Monday, 24 March 2014 at 01:34:22 UTC, Matej Nanut wrote:
Hello!
You can implement static functions that act like members, like
so:
---
void myFunc(MyClass c) { ... }
---
Which you will be able to call like:
---
auto c = new MyClass();
c.myFunc();
---
because of uniform function call
On Mon, 24 Mar 2014 16:02:25 -0400, MarisaLovesUsAll maru...@2ch.hk
wrote:
On Monday, 24 March 2014 at 01:34:22 UTC, Matej Nanut wrote:
Hello!
You can implement static functions that act like members, like so:
---
void myFunc(MyClass c) { ... }
---
Which you will be able to call like:
Hi! I didn't find how to implement functions outside the class,
like in C++.
C++:
class MyClass
{
void myFunc();
};
void MyClass::myFunc() { ... }
Is it possible to do this in D ?
Sorry for my bad English.
Regards,
Alexey
MarisaLovesUsAll:
C++:
class MyClass
{
void myFunc();
};
void MyClass::myFunc() { ... }
Is it possible to do this in D ?
It's not possible. Some people want it to happen, some other
people hate it.
Bye,
bearophile
On Sunday, 23 March 2014 at 21:48:33 UTC, MarisaLovesUsAll wrote:
Hi! I didn't find how to implement functions outside the class,
like in C++.
C++:
class MyClass
{
void myFunc();
};
void MyClass::myFunc() { ... }
Is it possible to do this in D ?
Sorry for my bad English.
Regards,
Alexey
On Sunday, 23 March 2014 at 22:20:39 UTC, John Colvin wrote:
On Sunday, 23 March 2014 at 21:48:33 UTC, MarisaLovesUsAll
wrote:
Hi! I didn't find how to implement functions outside the
class, like in C++.
C++:
class MyClass
{
void myFunc();
};
void MyClass::myFunc() { ... }
Is it possible
Hello!
You can implement static functions that act like members, like so:
---
void myFunc(MyClass c) { ... }
---
Which you will be able to call like:
---
auto c = new MyClass();
c.myFunc();
---
because of uniform function call syntax (UFCS).
But they won't be real methods (virtual member