>> Or does the compiler handle them like any
>> other
>> function and just thinks of a name itself ?
>
> Exactly. If you compile with DMD and the -v flag you can see what names it
> gives them.
:) nice
Thanks!
Hello Saaa,
Hello Saaa,
How should I do this then?
C c;
C2 c2 = new C2;
C3 c3 = new C3;
c=c2;
auto dg = { return c.method(); };
c=c3;
I actually did it like this before :) Thanks
But like this I need to do the "c is null" checking within the
function
literal.
I'm not sure how these functi
> Hello Saaa,
>
>> How should I do this then?
>
> C c;
> C2 c2 = new C2;
> C3 c3 = new C3;
> c=c2;
>
> auto dg = { return c.method(); };
>
> c=c3;
I actually did it like this before :) Thanks
But like this I need to do the "c is null" checking within the function
literal.
I'm not sure how these
Hello Saaa,
How should I do this then?
C c;
C2 c2 = new C2;
C3 c3 = new C3;
c=c2;
auto dg = { return c.method(); };
c=c3;
Hello Saaa,
"Daniel Keep" wrote in message
news:h88i4n$235...@digitalmars.com...
Saaa wrote:
"Daniel Keep" wrote in message
news:h88cck$1or...@digitalmars.com...
Saaa wrote:
abstract class C
{
int method();
}
class C2:C
{
int method() return 2;
}
class C3:C
{
int method() return 3;
}
i
>
> class Foo
> {
> C* c;
>
> this(ref C c)
> {
>this.c = &c;
> }
>
> int invoke()
> {
>return (*c).method();
> }
> }
>
> void main()
> {
> // ...
> deleg = &(new Foo(c)).invoke;
> }
>
> Or something similar.
>
> This is dangerous. Do not allow either the Foo instance or the deleg
Saaa wrote:
> Ok, disregard my last comment :D
> How should I do this then?
class Foo
{
C* c;
this(ref C c)
{
this.c = &c;
}
int invoke()
{
return (*c).method();
}
}
void main()
{
// ...
deleg = &(new Foo(c)).invoke;
}
Or something similar.
This is dangerous. Do n
"Daniel Keep" wrote in message
news:h88i4n$235...@digitalmars.com...
>
>
> Saaa wrote:
>> "Daniel Keep" wrote in message
>> news:h88cck$1or...@digitalmars.com...
>>>
>>> Saaa wrote:
abstract class C
{
int method();
}
class C2:C
{
int method() return 2;
"Ary Borenszweig" wrote in message
news:h88i6o$23h...@digitalmars.com...
> Saaa wrote:
>> "Daniel Keep" wrote in message
>> news:h88cck$1or...@digitalmars.com...
>>>
>>> Saaa wrote:
abstract class C
{
int method();
}
class C2:C
{
int method() return 2;
Saaa wrote:
"Daniel Keep" wrote in message
news:h88cck$1or...@digitalmars.com...
Saaa wrote:
abstract class C
{
int method();
}
class C2:C
{
int method() return 2;
}
class C3:C
{
int method() return 3;
}
int delegate() deleg;
void main()
{
C c;
C2 c2 = new C2;
C3 c3 = new C3;
c=c2;
c
Saaa wrote:
> "Daniel Keep" wrote in message
> news:h88cck$1or...@digitalmars.com...
>>
>> Saaa wrote:
>>> abstract class C
>>> {
>>> int method();
>>> }
>>> class C2:C
>>> {
>>> int method() return 2;
>>> }
>>> class C3:C
>>> {
>>> int method() return 3;
>>> }
>>> int delegate() deleg;
>>>
"Daniel Keep" wrote in message
news:h88cck$1or...@digitalmars.com...
>
>
> Saaa wrote:
>> abstract class C
>> {
>> int method();
>> }
>> class C2:C
>> {
>> int method() return 2;
>> }
>> class C3:C
>> {
>> int method() return 3;
>> }
>> int delegate() deleg;
>> void main()
>> {
>> C c;
>> C
Saaa wrote:
> abstract class C
> {
> int method();
> }
> class C2:C
> {
> int method() return 2;
> }
> class C3:C
> {
> int method() return 3;
> }
> int delegate() deleg;
> void main()
> {
> C c;
> C2 c2 = new C2;
> C3 c3 = new C3;
> c=c2;
> deleg = &c.method;
> writefln(deleg()); // 2
>
abstract class C
{
int method();
}
class C2:C
{
int method() return 2;
}
class C3:C
{
int method() return 3;
}
int delegate() deleg;
void main()
{
C c;
C2 c2 = new C2;
C3 c3 = new C3;
c=c2;
deleg = &c.method;
writefln(deleg()); // 2
c=c3;
writefln(deleg()); // 2
// I expected this to wr
14 matches
Mail list logo