types of constructors in c++

tanvisharma

tanvisharma

@tanvisharma-wSaer7 Oct 22, 2024
i want some clarity between different types of constructors in c++,
can anybody help me....
i want to see the code too...

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • vinci

    vinci

    @vinci-e4PtMU Feb 6, 2012

    1 default construtors
    2 copy constructors
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Feb 7, 2012

    3 super constructors
  • aarthivg

    aarthivg

    @aarthivg-HH344f Feb 7, 2012

    1.Parametrized constructors:

    constructors that can take arguments are termed as parametrized constructors. The number of arguments can be greater or equal to one.
    2.Default constructors:

    <a href="https://en.wikipedia.org/wiki/Default_constructor" target="_blank" rel="nofollow noopener noreferrer">Default Constructor</a> define the actions to be performed by the compiler when a class object is instantiated without actual parameters. Its sole purpose is to save the data members from the garbage value. It initialize the data members with the default values.
    3.Dynamic constructors:

    Allocation of memory to objects at the time of their construction is known as dynamic construction of objects and such constructors are called as dynamic constructors.
    4.Copy constructors:

    <a href="https://en.wikipedia.org/wiki/Copy_constructor" target="_blank" rel="nofollow noopener noreferrer">Copy Constructor</a> define the actions performed by the compiler when copying class objects. A copy constructor has one formal parameter that is the type of the class.
    5.Conversion constructor:

    Conversion constructors provide a means for a compiler to implicitly create an object of a class from an object another type. This type of constructor is different from copy constructor because it creates an object from other class. but copy constructor is from the same class.