About 50 results
Open links in new tab
  1. What are the rules for calling the base class constructor?

    1190 Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization …

  2. Can I call a constructor from another constructor (do constructor ...

    Nov 21, 2008 · When calling a constructor it actually allocates memory, either from the stack or from the heap. So calling a constructor in another constructor creates a local copy.

  3. What's the difference between an object initializer and a constructor?

    Apr 11, 2009 · 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 …

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

    Nov 13, 2013 · What is the purpose of a constructor? I've been learning Java in school and it seems to me like a constructor is largely redundant in things we've done thus far. It remains to be seen if a …

  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. c++ - Initializing fields in constructor - initializer list vs ...

    6 In your example code, the first one in constructor initialization and second one is assignment inside constructor body. Constructor initialization list is the best way to do all member initialization because …

  7. Can a constructor in Java be private? - Stack Overflow

    May 12, 2010 · Yes, a constructor can be private. There are different uses of this. One such use is for the singleton design anti-pattern, which I would advise against you using. Another, more legitimate …

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

  9. c++ - no default constructor exists for class - Stack Overflow

    Feb 13, 2011 · 80 If you define a class without any constructor, the compiler will synthesize a constructor for you (and that will be a default constructor -- i.e., one that doesn't require any arguments).

  10. Constructor of an abstract class in C# - Stack Overflow

    Apr 8, 2011 · An abstract class can have constructor and destructor. An abstract class cannot be a sealed class because the sealed modifier prevents a class from being inherited.