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
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.
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
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
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++,
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
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*
On 01/31/2012 12:41 PM, Trass3r wrote:
*whispers gee dee c*
windows binaries please...
*whispers gee dee c*
windows binaries please...
Seek and you shall find.
https://bitbucket.org/goshawk/gdc/downloads