These are chat archives for rust-lang/rust
Bstruct is a part of the
Astruct, it is possible with some unsafe hacks (
And there are some problems with constructors from the language point of view:
what is the value of the members in constructors body (
null in Java, so calling any mehod from ctor is a trouble waiting to happen, or a separate langauge for initializer fields in C++).
what if you want to have several constructors with the same arguments (Joshua Bloch of effective Java advices to use factory methods instead of constructors)
It's difficult to do constructor-based polymorphism (contrast Rust
From with Java's abundance of factory objects and C++ special rules around default initialization and single argument constructors) .
selfin the constructor?
thisis that of the class in which the constructor is defined
thisis that of the most-derived class - the one actually being instantiated
in C++ this means that if you call virtual methods from the constructor
Is't this just plain UB?
in C++ an object is an instance of the base class even if a more derived class is being constructed
typeid will return the id of the base class?