struct aliases
torhu
no at spam.invalid
Wed Nov 14 13:44:27 PST 2007
Kenny B wrote:
> Ok, I have reduced my code to a simple example... This is what I have:
>
> class MyClass {
> struct Data {
> int val1;
> int val2;
> }
>
> Data data;
> void one_function() {
> // stuff
> }
> }
>
> MyClass c = new MyClass;
> // I want to say this:
> c.val1 = 5;
I think this is planned for D 2.0, you will be able to put something
like 'alias data this;' in the class. Then you get the effect you want.
Maybe you could just use a template mixin to get the effect you want?
Depends on what you're really trying to achieve, of course.
template Data {
int val1;
int val2;
}
class MyClass {
mixin Data;
}
More information about the Digitalmars-d-learn
mailing list