-1

i am studying c++... and i have come across the topic constructors.. and in that i am confused between ...basic constructors, copy constructors, dynamic constructors... please explain what are these and also the program in which they can be used...???

3
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by crescendo
0

basic constructors

Constructors are basically a way to force initialization of class members.

copy constructors

Copy Constructors are used when you need to copy your class object to another object and the default copy constructor won't do the job.

You might want to bookmark that site, I find it to be a very good reference for C++

Edited by tinstaafl

0

A constructor is a special method that is created when the object is created or defined. This particular method holds the same name as that of the object and it initializes the instance of the object whenever that object is created. The constructor also usually holds the initializations of the different declared member variables of its object. Unlike some of the other methods, the constructor does not return a value, not even void.

A copy constructor is a special constructor in the C++ programming language for creating a new object as a copy of an existing object. The first argument of such a constructor is a reference to an object of the same type as is being constructed (const or non-const), which might be followed by parameters of any type (all having default values).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.