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

Leave a Comment

Your email address will not be published. Required fields are marked *

To Resolve this issue at just 5$ from ServerExpert

https://serverexpert.io/

For Hosting please visit Hostingwebsite.io

You have Successfully Subscribed!

Open chat