Re: class initialization

2018-01-16 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 16 January 2018 at 03:23:20 UTC, Marc wrote: But can't figure out if D does have that for classes. I believe there's no such thing for classes, you're supposed to use constructors. Class objects are in many aspects more abstract things than POD structs: instead of accessing

class initialization

2018-01-15 Thread Marc via Digitalmars-d-learn
in C# you can initilizate the class members like this: var foo = new Foo { a = 1, b = 2 }; I found something similar to structs in D: myStruct S = {a:1, b:2}; But can't figure out if D does have that for classes.

Re: Class Initialization

2012-02-01 Thread Vijay Nayar
The basic idea is that in D, any statically identifiable information (known at compile-time), can be used to assign class members as they are declared. Any time a new object is created, it will take those default values specified for its members. This is a small example demonstrating

Class Initialization

2012-01-31 Thread Zachary Lund
In C++, they provide a mechanism to initialize class variables to a passed value. class Test { int bob; public: Test(int jessica) : bob(jessica) { } }; The above basically says int this.bob = jessica; as opposed to this: class Test { int bob; public: Test(int

Re: Class Initialization

2012-01-31 Thread Andrej Mitrovic
On 1/31/12, Jonathan M Davis jmdavisp...@gmx.com wrote: In D however, the _entire_ type is created and default initialized before the first constructor is called. I was reading the C++ Object Model book recently (well, I'm still reading) and was amazed at how many edge-cases there are in C++,

Re: Class Initialization

2012-01-31 Thread H. S. Teoh
On Tue, Jan 31, 2012 at 08:49:25PM +0100, Andrej Mitrovic wrote: On 1/31/12, Jonathan M Davis jmdavisp...@gmx.com wrote: In D however, the _entire_ type is created and default initialized before the first constructor is called. I was reading the C++ Object Model book recently (well, I'm

Re: Class Initialization

2012-01-31 Thread Trass3r
I was reading the C++ Object Model book recently (well, I'm still reading) and was amazed at how many edge-cases there are in C++, and how lucky I am to be using D. Well, minus the Optlink that is. :) *whispers gee dee c*

Re: Class Initialization

2012-01-31 Thread bls
On 01/31/2012 12:41 PM, Trass3r wrote: *whispers gee dee c* windows binaries please...

Re: Class Initialization

2012-01-31 Thread Trass3r
*whispers gee dee c* windows binaries please... Seek and you shall find. https://bitbucket.org/goshawk/gdc/downloads