Steven Schveighoffer <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #3 from Steven Schveighoffer <> 2010-10-16 
09:50:22 PDT ---
(In reply to comment #1)
> It should be noted that unlike C++ this isn't necessarily a problem in D. In
> C++, each class in the class's hierarchy is constructed one by one until the
> most derived class constructor is called. So, if you call a virtual function 
> in
> a constructor, the object is not in a safe state and won't even correctly know
> what type it is.

In C++, calling a virtual function from a constructor calls that class' version
of the virtual function directly.  In other words, virtual functions are not
virtual inside the constructor.

In D, the virtual function is called, so it could potentially be a problem. 
However, it's also possible in D (unlike in C++) to initialize data before
calling the parent constructor through the use of super.  But of course, the
base class has no say in whether the derived class's version is safe to call. 
So yes, I think it would be a good thing to suggest as a "best practice" 
(certainly not a compiler error or warning), but there are ways to make it

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to