CONSTRUCTOR WITH ARGUMENTS:
#include<conio.h>
class add
{
int num1, num2, sum=0;
public()
{
add( int a, int b) \\ CONSTRUCTOR WITH ARGUMENTS \\
add( int a, int b) \\ CONSTRUCTOR WITH ARGUMENTS \\
{
num1=a;
num1=a;
num2=b;
}
void addition()
{
sum=num1+num2;
}
void display()
{
cout <<"\n NUM1= " <<num1;
cout <<"\n NUM2= " <<num2;
cout <<"\n SUM = " <<sum;
}
};
void main()
{
clrscr();
clrscr();
add a(50, 60) ;
a.addition();
a.display();
getch();
}
No comments:
Post a Comment