Top "Constructor" questions

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

C# member variable initialization; best practice?

Is it better to initialize class member variables on declaration private List<Thing> _things = new List<Thing&…

c# constructor declaration
C++ Abstract Class: constructor yes or no?

A class with one (or more) virtual pure functions is abstract, and it can't be used to create a new …

c++ class constructor abstract
base() and this() constructors best practices

Under what conditions am I supposed to make the :base() and :this() constructor calls following my constructor's parentheses (or even …

c# oop inheritance constructor instantiation
What's the difference between an object initializer and a constructor?

What are the differences between the two and when would you use an "object initializer" over a "constructor" and vice-versa? …

c# .net constructor object-initializer
Is there a generic constructor with parameter constraint in C#?

In C# you can put a constraint on a generic method like: public class A { public static void Method<…

c# generics parameters constructor generic-constraints
Javascript: TypeError: ... is not a constructor

I have a TypeError problem: function artist(name) { this.name = name; this.albums = new Array(); this.addAlbum = function(albumName) { for (…

javascript object constructor typeerror
Does the default constructor initialize built-in types?

Does the default constructor (created by the compiler) initialize built-in-types?

c++ constructor initialization default-constructor built-in-types
C++ Constructor/Destructor inheritance

EDIT : Summary of answers In the following, B is a subclass of A. It's a matter of terminology; ctors and …

c++ inheritance constructor destructor
Java :Setter Getter and constructor

I'm a bit confused about the use of getter/setters and constructors (see the below code for an example) public …

java class constructor setter getter
How to initialize a const field in constructor?

Imagine I have a C++ class Foo and a class Bar which has to be created with a constructor in …

c++ constructor constants ctor-initializer