c2 classes
Ali
fakeemail at example.com
Fri Apr 6 14:43:25 UTC 2018
On Friday, 6 April 2018 at 14:31:49 UTC, Alex wrote:
> 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);
>
> }
> ```
A question from me, since I am also still learning D
what is the difference between those following two declarations
> UUsers[int] uid; UUsers[] uid;
More information about the Digitalmars-d-learn
mailing list