Enter a place with calculating addition of three numbers. Using C++ Complete the missing statements (Comment lines) 1 #include 2 using namespace std; 3 4 //declare a class 5 { //access specifier 6 int c1; 7 public: 8 void setClass1(int n1){ 9 //assignment 10 cout<<"Number 1 = "<
Enter a place with calculating addition of three numbers.
Using C++ Complete the missing statements (Comment lines)
1 #include <iostream>
2 using namespace std;
3
4 //declare a class
5 { //access specifier
6 int c1;
7 public:
8 void setClass1(int n1){
9 //assignment
10 cout<<"Number 1 = "<<c1<<endl;
11 }
12 int getData1(){ return c1; }
13 };
14
15 //declare a class
16 { //access specifier
17 int c2;
18 public:
19 void setClass2(int n2){
20 //assignment
21 cout<<"Number 2 = "<<c2<<endl;
22 }
23 int getData2(){ return c2; }
24 };
25
26 //declare a class
27 { //access specifier
28 int c3;
29 public:
30 void setClass3(int n3){
31 //assignment
32 cout<<"Number 3 = "<<c3<<endl;
33 }
34 int getData3(){ return c3; }
35 void display(){ cout<<"Number 1 + Number 2 - Number 3 = "<<c1+c2-c3; }
36 };
37
38 int main(){
39 //declare object for the class
40 number.setClass1(1);
41 number.setClass2(2);
42 number.setClass3(3);
43 //call the display function
44 return 0;
45 }
Step by step
Solved in 2 steps with 1 images