c2 classes

Alex sascha.orlov at gmail.com
Fri Apr 6 14:31:49 UTC 2018


On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote:
> its possible to make this work ??
>
> import std.stdio;
>
>
> class UUsers
> {
> public:
>     int age;
> }
>
>
> class users
> {
> public:
>     int[int] uid;
>
> }
>
>
> void main() {
> 	
> 	users newuser = new users();
> 	newuser.uid[0].age = 23;
> 	writeln(newuser.uid[0].age);
>
> }

It depends on what you want to achieve...
This is runnable:
```
import std.stdio;


class UUsers
{
	this(int val)
	{
		age = val;
	}
public:
     int age;
}


class users
{
public:
     UUsers[int] uid;

}


void main() {
	
	users newuser = new users();
	newuser.uid[0] = new UUsers(23);
	writeln(newuser.uid[0].age);

}
```


More information about the Digitalmars-d-learn mailing list