default-value

How do I specify default argument values for a C++ constructor?

Hi, I have a constructor declaration as: MyConstuctor(int inDenominator, int inNumerator); and definition as MyConstuctor::MyConstuctor(int inDenominator, int inNumerator, int inWholeNumber = 0) { mNum = inNumerator; mDen = inDenominator; mWhole = inWholeNumber; } but i want to have an option of passing whole numbe...

Initializing final fields - Java

I would like to know if there's a compiler option that could allow me to remove/cure the error that comes up ("variable X might not have been initialized") when I compile a class who has a final field in it. Or even better would be to have the final fields initialized to the default java value. Thanks, ExtremeCoder ...

OptionalAttribute parameter's default value?

MSDN's VS2010 Named and Optional Arguments (C# Programming Guide) tells us about optional parameters in C#, showing code like I'd expect: public void ExampleMethod(int required , string optionalstr = "default string" , int optionalint = 10) Ok, but it also says: You can also decl...

How do I change the default preference for TIME_12_24?

The default time setting in Android is for a 24-hour clock. I would like to set it (the default, not the setting) to be a 12-hour clock instead. How do I do this? ...

solving default garbage values in c

If we declare a variable in c programming as integer without defining value then printf prints some garbage value from buffer. Is there any method to prevent printing the garbage value? I want to check if something can be done at compile time? if possible? ...

Offer current date in Rails

I want to offer the current date to the user when a new record is created and I want to allow him to edit the offered date. For example I write a bug tracking system and I have a date_of_detection field. 99% of the time it is good if it is the current date, but for the sake of the 1% the user should be allowed to edit it and set any earl...

Why can't a text column have a default value in MySQL?

If you try to create a TEXT column on a table, and give it a default value in MySQL, you get an error (on Windows at least). I cannot see any reason why a text column should not have a default value. No explanation is given by the MySQL documentation. It seems illogical to me (and somewhat frustrating, as I want a default value!). Anybod...

Using XML decorations to specify default values during de-serialization

I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. <element1 />). This is a problem for certain elements, for example, those that are meant to store integers. I have control over the third party, so I c...

Setting default value of DateTimePicker

Currently my DateTimePickers are blank, I would like them to have a default setting i.e Today.AddYears(20); & Today.AddDays(5); What I have done at the moment is 'DateTimePicker.Text = DateTime.Today.AddYears(-100).ToString();' As you can probably tell, this isn't working hence why I'm asking the question. Bit of information :- I nee...

Setting the default value of a function input to equal another input in Python

Hello, Consider the following function, which does not work in Python, but I will use to explain what I need to do. def exampleFunction(a, b, c = a): ...function body... That is I want to assign to variable c the same value that variable a would take, unless an alternative value is specified. The above code does not work in pytho...

Is applying default values to properties good or bad practice?

Is it good or bad practice to apply System.ComponentModel.DefaultValue default values to my properties? What about my ViewModel properties? I ask because I'm passing a ViewModel into my Controller. This ViewModel contains properties such as OrderByColumn, SortDirection and PageSize. When the page first loads, these need to be set to som...

Default value for parameter in Controller Method is overriding everything

Hello i have just started learning mvc2 and im having a problem with the default value for the parameter page(you can see the method below). Its always 0 regardless of what i type in the URL. For example this h.ttp://localhost:52634/Products/List/2 should show page 2 but when in debug mode the page parameter is 0, so im always gettin...

Why contract is malformed when using default(Type)?

Hi, When compiling code which uses code contracts, I have a very strange error I don't understand. [ContractInvariantMethod] private void ObjectInvariant() { Contract.Invariant( this.isSubsidiary || this.parentCompanyId == default(Guid)); } fails with the following error: Malformed contract. Found Invariant af...

PHP object default return value

I have a function which returns object array like that: <?php function sth() { return (object) array( "obj1" => $obj1, "obj2" => $obj2, "obj3" => $obj3 ); } $obj = sth(); echo $obj; ?> Here I want to define $obj's default value.It will return default value instead of $obj1,$obj2,$obj3. How can I define a defa...

Initializing default values for private fields in constructors explicitely.. WTF?

Consider the following code snippet from .NET 4.0 library: private T[] array; private static T[] emptyArray; private int size; private int version; static Stack() { Stack<T>.emptyArray = new T[0]; } public Stack() { array = Stack<T>.emptyArray; size = 0; version = 0; } Is there any reason behind initiali...

reset a form to the default values

Currently I have: $("#your_email").val(this.defaultValue;) I want to be cycling through all form elements and resetting them to their default value ...

Using rdb$get_context as default value for a column

In a Firebird database, I need to create a DOMAIN with default value taken from the context variable. It should be something like CREATE DOMAIN USER_ID AS INTEGER DEFAULT RDB$GET_CONTEXT('USER_SESSION','UID') NOT NULL; When I execute this, I am getting the following error Invalid token. Dynamic SQL Error. SQL error code = ...

Good jQuery Plugin for a Form Field Initial or Default Value?

What is a good jQuery plugin for a showing default value in an input box that disappears when it gets focus or a user starts entering text? ...

map default column value with annotations

@Entity @Table(name = "J_CNTRY") public class CountryEntity { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "myTableGenerator") @TableGenerator(name = "myTableGenerator", allocationSize = 5, pkColumnName = "pkName", valueColumnName = "pkValue", table = "j_cntry_pk_table") private Long id; private ...

Defaulting Column in SharePoint DataView Insert Mode to a QueryString Parameter

I have a SharePoint Dataview with a Querystring parameter. I am able to use the Parameter in a Datasource filter. I've enabled the New button and it works. There is a column in my view that is required. I really don't want to display it in my DataView, but must. When I select Insert, the column (a lookup dropdown), comes up. I'd l...