You are on page 1of 7

(

Write a program using copy constructure

#include<iostream.h >
#include<conio.h>
class copy
{
int var,fact;
public:
copy(int temp)
{
var=temp;
}
double calculate()
{
fact=1;
for (int i=1; i<=var; i++)
{
fact=fact*i;
}

return fact;
}
};
void main()
{
clrscr();
int n;
cout<<"\n\tenter the number:";
cin>>n;
copy obj(n);
copy cpy=obj;
cout<<"\n\t"<<n<<"factorial is:"<<obj.calculate();
getch ();
};

Output ::

You might also like