Class Initialization
Zachary Lund
admin at computerquip.com
Tue Jan 31 10:07:16 PST 2012
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 jessica) { bob = jessica; }
};
which basically says "int this.bob = void; bob = jessica;". Now, I'm not
a speed freak but this is a quick and should be a painless optimization.
D allows defaults set by the class but cannot seem to find anything to
allow me variable initialization values. Not that it's that big of a
deal but am I missing something?
More information about the Digitalmars-d-learn
mailing list