Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
Filling in 1 references using Reflinks
Line 249:
=== Failure ===
 
A constructor that cannot create a valid value should throw an [[Exception handling|exception]]. This is because exceptions should be thrown when [[Postcondition|post-conditions]] cannot be met, and the post-condition of a constructor is the existence of a valid object. An object which throws during its constructor never comes into existence (although some of its member objects might). This affects how one handles errors and special consideration must be given for exceptions emitted by member variables' constructors.<ref>[{{cite web|url=http://www.gotw.ca/gotw/066.htm] |title=GotW #66: Constructor Failures |publisher=Gotw.ca |date=2000-02-02 |accessdate=2013-01-19}}</ref>
 
=== F# ===