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

Recommended Answers

All 2 Replies

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++

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.