Top "Default-constructor" questions

A default constructor is a parameterless constructor, often generated by the compiler.

Why don't std::vector's elements need a default constructor?

And how can I write my own array class to not need a default constructor for its elements? Right now, …

c++ vector default-constructor
uninitialized const

This compiles perfectly fine with the current MSVC compiler: struct Foo { } const foo; However, it fails to compile with the …

c++ visual-c++ g++ constants default-constructor
Why is super class constructor always called

I have the following 2 classes public class classA { classA() { System.out.println("A"); } } class classB extends classA { classB() { System.out.…

java inheritance superclass default-constructor
C# - Calling a struct constructor that has all defaulted parameters

I ran into this issue today when creating a struct to hold a bunch of data. Here is an example: …

c# struct optional-parameters default-constructor
Why does the default parameterless constructor go away when you create one with parameters

In C#, C++ and Java, when you create a constructor taking parameters, the default parameterless one goes away. I have …

c# java c++ default-constructor
Class member without a default constructor

Suppose I have a class A without a default constructor, a factory method factoryA that returns an object of type …

c++ default-constructor initialization-list
How to mock the default constructor of the Date class with JMockit?

I want to mock the default constructor of java.util.date so it does not construct a Date object representing …

java default-constructor jmockit
Any way to call the default constructor from a parameterized constructor?

Suppose, I have the following code class C { int i; String s; C(){ System.out.println("In main constructor"); // Other …

java default-constructor parameterized-constructor