Passing this to void *
Tim Hsu
tim37021 at gmail.com
Wed Nov 22 15:11:08 UTC 2017
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch wrote:
> On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote:
>> I am a C++ game developer and I want to give it a try.
>>
>> It seems "this" in Dlang is a reference instead of pointer.
>>
>> How can I pass it as void *?
>>
>> void foo(void *);
>>
>> class Pizza {
>> public:
>> this() {
>> Pizza newone = this;
>> // works but newone is actually not this pizza.
>> foo(&newone);
>> // this does not work..
>> foo(this);
>> }
>> }
>>
>> void main() {
>> Pizza pizza = new Pizza();
>> // this works...
>> foo(&pizza);
>> }
>
> &this will do.
I've tried it in the first place.
...
Error: this is not an lvalue
More information about the Digitalmars-d-learn
mailing list