About 11,800,000 results
Open links in new tab
  1. Can a struct have a constructor in C++? - Stack Overflow

    Sep 10, 2023 · In C++ the only difference between a class and a struct is that members and base classes are private by default in classes, whereas they are public by default in structs. So …

  2. Why do we need a constructor in OOP? - Stack Overflow

    Oct 17, 2014 · The constructor IS the "Initialize function" Rather than calling two functions object = new Class; object.initialize(); You just call object = new Class(); The logic inside the …

  3. Constructor overload in TypeScript - Stack Overflow

    Oct 3, 2012 · I want to do constructor overloading in TypeScript. On page 64 of the language specification (v 0.8), there are statements describing constructor overloads, but there wasn't …

  4. When is it right for a constructor to throw an exception?

    The constructor's job is to bring the object into a usable state. There are basically two schools of thought on this. One group favors two-stage construction. The constructor merely brings the …

  5. C++: Where to initialize variables in constructor - Stack Overflow

    If you do not mention a variable in a class's initialization list, the constructor will default initialize it before entering the body of the constructor you've written. This means that option 2 will lead to …

  6. C# : assign data to properties via constructor vs. instantiating

    Oct 2, 2013 · Would you really want to have a constructor that has 20 different properties - especially when you only want to actually define one or two? Secondly, default values don't …

  7. C++, What does the colon after a constructor mean?

    May 7, 2010 · An initializer list is how you pass arguments to your member variables' constructors and for passing arguments to the parent class's constructor. If you use = to assign in the …

  8. function - Purpose of a constructor in Java? - Stack Overflow

    Nov 13, 2013 · A constructor is the means of creating an instance of your class by creating an object in memory and returning a reference to it. Something that should happen in the …

  9. base() and this() constructors best practices - Stack Overflow

    Sep 26, 2010 · Correct; the constructors are always chained, and each class calls its base class's constructors. Using this you get to reuse this class's other constructor (which itself will use …

  10. spring boot - Why to use @AllArgsConstructor and …

    Jul 9, 2021 · Constructor based Injection (@AllArgsConstructor): When you create object by passing all parameters, you basically use a constructor injection. It should be done when we …