Aim: Write a program to
demonstrate the typecasting of basic to
class type .
Ans:
#include<iostream.h>
#include<conio.h>
class A
{
public:
int z;
A (int sum)
{
z=sum;
}
void show()
{
cout<<"Sum
is:"<<z;
}
};
void main()
{
int a,b,sum;
clrscr();
cout<<"Enter the values you want to
add:\n";
cin>>a>>b;
sum=a+b;
A o1=sum;
o1.show();
getch();
}
No comments:
Post a Comment