Computer Science, asked by shirishabaddal, 10 months ago

Write a C++ program to define a class “Number” having data members x and y and
perform mathematical operations like addition, subtraction, multiplication and
division on two numbers using constructor and destructor functions.​

Answers

Answered by Raghav1330
16

Answer:code is provided.

Explanation:

For this the member function or the methods will be made public thus enabling all the methods to being public from outside of the class.

class number

{

public:

number()

{

int a, b;

cout<<“enter the numbers ";

cin>>a>>b;

}

int addition(a,b);

int divide(a,b);

int subtract(a,b);

int multiply(a,b) ;

~numbers() ;

}

The constructor function numbers is taking input for both operands and the arithmetic operation will be done by the members function when the arguments will be passed and the function Will be accessed from outside of the class.

Answered by keyboardavro
4

Answer:

Explanation:

For this the member function or the methods will be made public thus enabling all the methods to being public from outside of the class.

class number

{

public:

number()

{

int a, b;

cout<<“enter the numbers ";

cin>>a>>b;

}

int addition(a,b);

int divide(a,b);

int subtract(a,b);

int multiply(a,b) ;

~numbers() ;

}

The constructor function numbers is taking input for both operands and the arithmetic operation will be done by the members function when the arguments will be passed and the function Will be accessed from outside of the class.

Similar questions