digitalmars.D.learn - Is this actually valid code?
- Andrej Mitrovic (27/27) Nov 06 2011 I've had a simple problem where I've only wanted to override a setter
- Trass3r (1/13) Nov 07 2011 http://d-programming-language.org/hijack.html
- Steven Schveighoffer (5/32) Nov 07 2011 http://www.d-programming-language.org/function.html#function-inheritance
- Andrej Mitrovic (1/1) Nov 07 2011 Cool stuff, thanks guys. This thing kicks some serious C++ ass. ^^
- Trass3r (1/2) Nov 07 2011 How? You can use using in C++ to do the same.
- Andrej Mitrovic (2/4) Nov 07 2011 My bad. I was a bit over-excited there. :p
I've had a simple problem where I've only wanted to override a setter
from a base class:
class Foo
{
property void test(int) {}
property int test() { return 1; }
}
class Bar : Foo
{
override property void test(int) {}
void bartest() { auto x = test; } // NG
}
test.d(19): Error: function test.Bar.test (int _param_0) is not
callable using argument types ()
So I thought I'd be clever:
class Foo
{
property void test(int) {}
property int test() { return 1; }
}
class Bar : Foo
{
alias super.test test;
override property void test(int) {}
void bartest() { auto x = test; }
}
And it actually works! Is this a documented feature?
Nov 06 2011
class Foo
{
property void test(int) {}
property int test() { return 1; }
}
class Bar : Foo
{
alias super.test test;
override property void test(int) {}
void bartest() { auto x = test; }
}
And it actually works! Is this a documented feature?
http://d-programming-language.org/hijack.html
Nov 07 2011
On Sun, 06 Nov 2011 23:10:57 -0500, Andrej Mitrovic
<andrej.mitrovich gmail.com> wrote:
I've had a simple problem where I've only wanted to override a setter
from a base class:
class Foo
{
property void test(int) {}
property int test() { return 1; }
}
class Bar : Foo
{
override property void test(int) {}
void bartest() { auto x = test; } // NG
}
test.d(19): Error: function test.Bar.test (int _param_0) is not
callable using argument types ()
So I thought I'd be clever:
class Foo
{
property void test(int) {}
property int test() { return 1; }
}
class Bar : Foo
{
alias super.test test;
override property void test(int) {}
void bartest() { auto x = test; }
}
And it actually works! Is this a documented feature?
http://www.d-programming-language.org/function.html#function-inheritance
Look at the third example/description.
-Steve
Nov 07 2011
Cool stuff, thanks guys. This thing kicks some serious C++ ass. ^^
Nov 07 2011
Cool stuff, thanks guys. This thing kicks some serious C++ ass. ^^How? You can use using in C++ to do the same.
Nov 07 2011
On 11/7/11, Trass3r <un known.com> wrote:My bad. I was a bit over-excited there. :pCool stuff, thanks guys. This thing kicks some serious C++ ass. ^^How? You can use using in C++ to do the same.
Nov 07 2011









Trass3r <un known.com> 