CPP Dynamic Constructor

Dynamic Constructor

  • Dynamic constructor is used to allocate the memory to the objects at the run time.
  • Memory is allocated at run time with the help of 'new' operator.
  • By using this constructor, we can dynamically initialize the objects.


#include <iostream.h>
#include <conio.h>
class dyncons
 int * p;
  p=new int;
 dyncons(int v)
  p=new int;
 int dis()
 { return(*p);
void main()
dyncons o, o1(9);
cout<<"The value of object o's p is:";
cout<<"\nThe value of object 01's p is:"<<o1.dis();


The value of object o's p is:10
The value of object 01's p is:9

Subscribe us on Youtube

Share This Page on


Rampal punia | 06-May-2018 08:04:00 am

It is very simple definition of dynamic cons.. .. and much understandable... 💥💥💥💥💥

satpal | 23-Oct-2018 12:16:58 pm

chutia hai tu

Ask Question