c++ to display the values we are passing from parameterised constructor.

//To display the values of parameterised constructor.
#include<iostream>
using namespace std;

class add
{
int num1,num2,sum;
public :
add(int x,int y);
void display();
};
add::add(int x,int y)
 {
num1=x;
num2=y;
sum=x+y;
 }
void add::display()
 {
cout<<"The nummbers are "<<num1<<"\t"<<num2<<"\n";
 }
int main()
  {
 add b=add(10,20);
 b.display();
  }



OUT-The numbers are 10 20

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation