Write a program to use dynamic constructor


 

/* Write a program to use dynamic constructor*/

#include<iostream.h>

#include<conio.h>

class sum

{

public:

sum(int a,int b)

{

int c;

c=a+b;

cout<<“c=”<<c<<endl;

}};

void main()

{

int a,b;

clrscr();

cout<<“enter a and b=”;

cin>>a>>b;

sum s(a,b);

getch();

}

/*output:

enter a and b=10 20

c=30*/

Comments are closed.