About 11,800,000 results
Open links in new tab
  1. 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 …

  2. 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 …

  3. 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 …

  4. What are the rules for calling the base class constructor?

    Apr 4, 2021 · What are the C++ rules for calling the base class constructor from a derived class? For example, I know in Java, you must do it as the first line of the subclass constructor (and if …

  5. .NET Core DI, ways of passing parameters to constructor

    Dec 21, 2018 · Having the following service constructor public class Service : IService { public Service(IOtherService service1, IAnotherOne service2, string arg) { } } What are the choices of

  6. 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 …

  7. 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 …

  8. 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 …

  9. What's the difference between an object initializer and a …

    A constructor is a defined method on a type which takes a specified number of parameters and is used to create and initialize an object. An object initializer is code that runs on an object after a …

  10. 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 …