Questions tagged [object-initialization]

56 questions
0
votes
3 answers

StackOverFlowError in Java code

I am writing a simple code and I am receiving an StackOverflowError in following code at line 2: Tmp4 t = new Tmp4 (); I dont get error if I omit line 6 ( initialization of p) or on omiting line 2. Also I am not doing a recursive call. I want to…
0
votes
2 answers

Dependent fields when using object property initialisation in C#

I was quite suprised today to discover that I can't do the following. public class NumberyStuff { public List Numbers { get; set; } public int Total { get; set; } } var numbers = new NumberyStuff { Numbers = new List{ 1, 2,…
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
0
votes
1 answer

Scala : Calling methods of a class during object initialization

object Program { def main(args:Array[String])={ val parent = new Parent{ method() } } } class Parent{ def method(){ println("inside method") } } In the above code, I am instantiating a new instance of…
Aravindh S
  • 1,185
  • 11
  • 19
0
votes
3 answers

Java Generic object initialization

Please look at this snippet first : public MultiThreadManager( Class c) { T[] allJobs = (T[]) Array.newInstance( c , MAX_THREAD_SIZE ) ; for ( int i = 0 ; i < MAX_THREAD_SIZE ; i ++ ) { allJobs[i] = (T) new Object(); …
Akhil Soni
  • 73
  • 2
  • 11
0
votes
2 answers

Writing "reset" method, re-initializing objects not working - Java

I have attempted to create a reset method by "re-initializing" the objects in question to new objects. What is happening is that some of the values stored in the objects are being reset, as per the constructors, yet some are not. Can anyone explain…
0
votes
1 answer

Inheritance of the init function in php

So I have been thinking about this for a while and wondering if my init function is even working at all. This stems from the idea of object initialization in Zend Framework. Lets Assume I have a base class like such: class Base{ public function…
LogicLooking
  • 916
  • 1
  • 16
  • 32
0
votes
1 answer

ReSharper changes intellisense behaviour when initilizing objects

Let's assume I have a class public class Dummy { public int DummyInt { get; set; } public string DummyString { get; set; } } and somewhere in the code I have: var dummy = new Dummy { In VS10, if I press now 'a' I will get a list of…
0
votes
1 answer

Copy constructors in object initialization

Theoretical doubt here. Reading a book, and given this statement: StringBad metoo = knot; where: StringBad is a class knot is an object of that class the author says the following regarding copy constructors: implementations have the option of…
-1
votes
2 answers

Object initialization from single DataRow

To populate a List from a DataTable I typically write a statement like this: List foos = dt.AsEnumerable().Select(dr => new Foo { Bar = Convert.ToIn32(dr["Bar"]), Baz = Convert.ToDecimal(dr["Baz"]) }).ToList(); How may I…
Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
-1
votes
2 answers

Object initialization syntax in C++

I noticed a few strange errors when I was trying to initialize constructors. It's easiest if I just show them. #include class MyClass { public: int var1, var2, var3; MyClass() { var1, var2, var3 = 0; } …
-1
votes
1 answer

MVC view-controller

I start to learning MVC and I write my own MVC pattern, and I can do only main-controller and main-view, but I can't understand how to make another controller/action and I want to make some link from my main-view to another page. So I have next…
Nevada
  • 277
  • 1
  • 7
  • 13
1 2 3
4