default-parameters

C# 4 default parameter values: How to assign a default DateTime/object value?

If DateTime is an object and default C# parameters can only be assigned compile-time constants, how do you provide default values for objects like DateTime? I am trying to initialize values in a POCO with a constructor, using named parameters with default values. ...

Is there a significant mechanical difference between these faux simulations of default parameters?

C#4.0 introduced a very fancy and useful thing by allowing default parameters in methods. But C#3.0 doesn't. So if I want to simulate "default parameters", I have to create two of that method, one with those arguments and one without those arguments. There are two ways I could do this. Version A - Call the other method public string Cu...

Is there any way to set parameter default as function of previous parameter? [C++]

I assume not, but I just wanted to check - is there any way in C++ to do something like the following? Obviously when I try the below I get a scope-based error about bar. void foo(Bar bar, int test = bar.testInt) { ... } ...

Default parameter value for a TSomething in Delphi

I'd like to know if this is possible in Delphi (or if there's a clean way around it): type TSomething = record X, Y : Integer; end; GetSomething( x, y ) -> Returns record with those values. ... and then you have this function with TSomething as parameter, and you want to default it as function Foo( Something : TSomething = GetSo...

constructor with one default parameter

Suppose I have a class class C { C(int a=10); }; why if I call C c; the contructor C(int =10) is called and if I call C c(); the default constructor is called? How to avoid this? I want to execute only my constructor, I tried to make the default constructor private, but it doesn't work. ...

Scala extra no-arg constructor plus default constructor parameters

I am using the Scala 2.8 default parameters on a constructor, and for Java compatibility reasons, I wanted a no-arg constructor that uses the default parameters. This doesn't work for very sensible reasons: class MyClass(field1: String = "foo", field2: String = "bar") { def this() = { this() // <-- Does not compile, but how...