Re: Protected Members in Class

2021-12-24 Thread Paul Backus via Digitalmars-d-learn
On Friday, 24 December 2021 at 15:46:17 UTC, Salih Dincer wrote: On Friday, 24 December 2021 at 14:29:29 UTC, Paul Backus wrote: `protected` in D means "this symbol can only be accessed from (a) the module where it's defined, and (b) classes that inherit from the class where it's defined."

Re: Protected Members in Class

2021-12-24 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 24 December 2021 at 14:29:29 UTC, Paul Backus wrote: `protected` in D means "this symbol can only be accessed from (a) the module where it's defined, and (b) classes that inherit from the class where it's defined." Please, can you show me this?

Re: Protected Members in Class

2021-12-24 Thread Paul Backus via Digitalmars-d-learn
On Friday, 24 December 2021 at 12:10:32 UTC, Salih Dincer wrote: What is the difference between protected and private? Also how can a function outside of the class access it? `private` in D means "this symbol can only be accessed from the module where it's defined." `protected` in D

Re: Protected Members in Class

2021-12-24 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 24 December 2021 at 11:29:31 UTC, Salih Dincer wrote: ```d module app; class Any { protected/* private//*/ string Data; this(string data) { Data = data; } @property getData() { return Data; } } string getData(Any test) { return test.Data; } ``` What is the

Re: Protected Members in Class

2021-12-24 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 24 December 2021 at 10:26:37 UTC, apz28 wrote: https://dlang.org/spec/attribute.html#visibility_attributes #5 Okay, what about the 2nd question (super or this). ```d import app, std.stdio; void main() { auto any = new Any("int"); //any.get().writeln; /* assert(any.data ==

Re: Protected Members in Class

2021-12-24 Thread apz28 via Digitalmars-d-learn
On Friday, 24 December 2021 at 08:35:38 UTC, Salih Dincer wrote: What do I need to do to see that the protected is active, need a separate module? ```d // Source: https://tour.dlang.org/tour/en/basics/classes class Any { // protected is just seen by inheriting // classes protected

Re: Protected Members in Class

2021-12-24 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 24 December 2021 at 08:35:38 UTC, Salih Dincer wrote: What do I need to do to see that the protected is active, need a separate module? ```d // Source: https://tour.dlang.org/tour/en/basics/classes Addition made for one of the inherited class: ```d override string

Protected Members in Class

2021-12-24 Thread Salih Dincer via Digitalmars-d-learn
What do I need to do to see that the protected is active, need a separate module? ```d // Source: https://tour.dlang.org/tour/en/basics/classes class Any { // protected is just seen by inheriting // classes protected string type; this(string type) { this.type = type;