Quote:
quote:Originally posted by dhmderuiter
Indeed I could remove the default constructor, but then errors would only hit at runtime.
|
What do you mean? If you have only a constructor that expects value(s) then your code must call it and pass in some value. Presumably, you would not allow your code to pass in a value that hasn't be obtained from somewhere useful. Thus you ensure a properly constructed class.
Quote:
quote:Originally posted by dhmderuiter
My problem here is that Visual Studio doesn't warn you when you forget to set such parameters (I think). Do you know a solution to that?
|
Sort of: use a constructor that expects all the required values. If they are so important, why would you ever allow a default constructor that doesn't set them? (Apart from when you need to serialize a class. This requires a default, i.e. empty, constructor.)
-Peter