You are about to enter a place with calculating addition of three numbers. You need to complete the missing statements in Table 1, which can accomplish an output as shown in the figure below. class 1 class 2 class_3 IMPORTANT: Please write a C ++ statement WITHOUT ANY WHITE SPACE unless it is necessary. Example: float x-a+b; 1#include 2using namespace std; 3 4/|declare a class 5{ //access specifier 6 int cl; 7 public: 8 void setClass1(int nl){ 9 //assignment 10 cout<<"Number 1 = "<

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 5E
icon
Related questions
Question
100%

C++

You are about to enter a place with calculating addition of three numbers.
You need to complete the missing statements in Table 1, which can accomplish an output as
shown in the figure below.
class 1
class 2
class 3
IMPORTANT:
Please write a C ++ statement WITHOUT ANY WHITE SPACE unless it is necessary.
Example: float x=q+b;
1#include <iostream>
2using namespace std;
3
4/|declare a class
5{ //access specifier
6 int cl;
7 public:
8 void setClass1(int nl){
//assignment
10
cout<<"Number 1 = "<<cl<<endl;
11 }
12 int getDatal(){ return cl; }
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 = "<«cl+c2-c3; }
36};
37
38int 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}
Line Missing Statements
|4
15
19
15
16
20
26
27
31
39
43
What is the concept applied in Program 1?
Which class is the base class in Program 1?
Transcribed Image Text:You are about to enter a place with calculating addition of three numbers. You need to complete the missing statements in Table 1, which can accomplish an output as shown in the figure below. class 1 class 2 class 3 IMPORTANT: Please write a C ++ statement WITHOUT ANY WHITE SPACE unless it is necessary. Example: float x=q+b; 1#include <iostream> 2using namespace std; 3 4/|declare a class 5{ //access specifier 6 int cl; 7 public: 8 void setClass1(int nl){ //assignment 10 cout<<"Number 1 = "<<cl<<endl; 11 } 12 int getDatal(){ return cl; } 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 = "<«cl+c2-c3; } 36}; 37 38int 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} Line Missing Statements |4 15 19 15 16 20 26 27 31 39 43 What is the concept applied in Program 1? Which class is the base class in Program 1?
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr