On Thursday, 16 February 2017 at 02:17:49 UTC, Ali Çehreli wrote:
On 02/15/2017 05:49 PM, Jean Cesar wrote:
> So I'm a beginner in this language and have very little time
I started
> I'm interested in apprehending concepts of object orientation
> polymorphism inheritance, multiple inheritance as in c ++
D is similar to C++ but also very different.
> but I did not
> understand how to use constructor in it
> Because I simply did.
>
> Class person
> {
> person(){}
> ~ Person () {}
> }
>
> And error ...
In D, constructor is always called this():
class Person
{
this(){}
~this() {}
}
void main() {
auto p = new Person();
}
Ali
So I used get methods and sets only as initial pattern to
netender the functioning of the language in relation to some
concepts of the same I intend to learn it not because it is a new
language, but I want to understand how to leave a very small code
with the largest number of Possible functionality type I still do
not know very well or use constructors in C ++ but I have very
high potential in a code with multiple inheritance, I think of
compilers in the case of the code that favors me in reading so I
would do something like:
void main ()
{
minhaclasse c = new minhaclasse(string text);
minhaclasse d = new minhaclasse(int number);
write("Enter your name: ")
c.set();
write("Enter your age: ")
d.set();
/*
the set method would already fetch user i
imput by mistake for the information automatically
*/
Writeln
(
"\n\tString:", c.get (),
"\n\tInt:", d.get ()
);
}
Or something like:
void main ()
{
string txt;
Int num;
write("Enter your name: ")
minhaclasse(text).set();
write("Enter your age: ")
minhaclasse(num).set();
writeln
(
"\n\tString:", minhaclasse(text).print() ;,
"\n\tInt:", minhaclasse(num).print();
);
}
I think of object orientation this way to avoid getting rewritten
many things so I would only define what the set or get would
return by initializing the constructor only but I have no idea
how to do that ..
My goal in learning to use languages like Java, C ++, D is with
the intention of learning the best way to reuse code and
orienation to objects and also development cross-platform codes
that will run in standard ansi for, Unix, Linux, Windows, android
etc. ..