www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - this-pointer

reply F. Müller <F._member pathlink.com> writes:
Does D's keyword "this" exactly 'behave' the same as it does in C++ (from a
programmer's and not internal perspective)? Does it always hold the address of a
class'es instance?
Rephrased: Is the statement "this()" different from statement "this"? Or is
"this" an implicit constructor call?

I'm Asking because some compiler output is confusing me.

F. Müller
Jun 27 2004
next sibling parent reply "C. Sauls" <ibisbasenji yahoo.com> writes:
F. Müller wrote:
 Rephrased: Is the statement "this()" different from statement "this"? Or is
 "this" an implicit constructor call?
They are different. "this()" is a constructor call, and "this" is a referance to the active instance (as in C++).
 I'm Asking because some compiler output is confusing me.
What is the output? Maybe someone here will be able to explain it for you. -Chris S. -Invironz
Jun 28 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Mon, 28 Jun 2004 03:30:48 -0500, C. Sauls <ibisbasenji yahoo.com> wrote:
 F. Müller wrote:
 Rephrased: Is the statement "this()" different from statement "this"? 
 Or is
 "this" an implicit constructor call?
They are different. "this()" is a constructor call, and "this" is a referance to the active instance (as in C++).
 I'm Asking because some compiler output is confusing me.
What is the output? Maybe someone here will be able to explain it for you.
Doh! I should read em all before posting... Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 28 2004
prev sibling parent Regan Heath <regan netwin.co.nz> writes:
On Mon, 28 Jun 2004 06:24:54 +0000 (UTC), F. Müller 
<F._member pathlink.com> wrote:

 Does D's keyword "this" exactly 'behave' the same as it does in 
 C++ (from a
 programmer's and not internal perspective)? Does it always hold the 
 address of a
 class'es instance?
Yes.
 Rephrased: Is the statement "this()" different from statement "this"?
Yes, the former is a constructor call, the latter a reference to the class.
 Or is
 "this" an implicit constructor call?
No.
 I'm Asking because some compiler output is confusing me.
Post it here. :) Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 28 2004