Top "Constructor" questions

A special type of subroutine called at the creation of an object.

Calling the base constructor in C#

If I inherit from a base class and want to pass something from the constructor of the inherited class to …

c# .net inheritance constructor
What is the best way to give a C# auto-property an initial value?

How do you give a C# auto-property an initial value? I either use the constructor, or revert to the old …

c# constructor getter setter automatic-properties
How do I call one constructor from another in Java?

Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how? …

java constructor
How to initialize HashSet values by construction?

I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.…

java collections constructor initialization hashset
What are the rules for calling the superclass constructor?

What are the C++ rules for calling the superclass constructor from a subclass one? For example, I know in Java, …

c++ inheritance constructor
Can an abstract class have a constructor?

Can an abstract class have a constructor? If so, how can it be used and for what purposes?

java constructor abstract-class
Struct Constructor in C++?

Can a struct have a constructor in C++? I have been trying to solve this problem but I am not …

c++ struct constructor
Call one constructor from another

I have two constructors which feed values to readonly fields. public class Sample { public Sample(string theIntAsString) { int i = int.…

c# constructor
Can I call a constructor from another constructor (do constructor chaining) in C++?

As a C# developer I'm used to running through constructors: class Test { public Test() { DoSomething(); } public Test(int count) : this() { …

c++ constructor