Category "constructor"

Is there still a need to provide default constructors to use STL containers?

I remember that back in C++98, if you wanted to make an STL container of MyClass, you needed to provide default constructor to MyClass. Was this specific to som

Error: Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'

void main() { Car c1 = new Car('E1001'); } class Car { String engine; Car(String engine) { this.engine = engine; print("The engine is : ${engine}

Having trouble creating overloaded constructor, instantiating an object

I'm new with Java and I'm having trouble going along with my teacher's video lectures (I'm taking an online class), and I'm having trouble with this assignment:

Does a constructor has a "type" in C++ since it is a special member function

I recently learnt that constructors do not have names in C++ and some other things about them. I am also aware that a function has a type in C++ called a functi

Pass Parameter to Base Class Constructor while creating Derived class Object

Consider two classes A and B class A { public: A(int); ~A(); }; class B : public A { public: B(int); ~B(); }; int main() { A* aobj; B

Initialize field before super constructor runs?

In Java, is there any way to initialize a field before the super constructor runs? Even the ugliest hacks I can come up with are rejected by the compiler: cla

Laravel: Why is my variable not being set while it's in the construct function of the controller?

class Controller extends BaseController { use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests; private $host; private

How to create constructor of custom view with Kotlin

I'm trying to use Kotlin in my Android project. I need to create custom view class. Each custom view has two important constructors: public class MyView extend