Create a class with two public integers and functions for reading and displaying the sum of two numbers.
#include <iostream>
using namespace std;
class Integers{
private:
int number1;
int number2;
public:
void read(){
cout<<"Ente number1: ";
cin>>number1;
cout<<"Ente number2: ";
cin>>number2;
}
void display(){
cout<<"The sum of two numbers: "<<(number1+number2)<<"\n\n";
}
};
//The start point of the program
int main(){
Integers integers;
integers.read();
integers.display();
system("pause");
return 0;
}
Comments
Leave a comment