CrazyEngineers
  • types of constructors in c++

    tanvisharma

    tanvisharma

    @tanvisharma-wSaer7
    Updated: Oct 22, 2024
    Views: 1.0K
    i want some clarity between different types of constructors in c++,
    can anybody help me....
    i want to see the code too...
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • vinci

    MemberFeb 6, 2012

    1 default construtors
    2 copy constructors
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberFeb 7, 2012

    3 super constructors
    Are you sure? This action cannot be undone.
    Cancel
  • aarthivg

    MemberFeb 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.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register