1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jeka94
3 years ago
15

Given ProblemSolution class. Use a pointer to object of "ProblemSolution" class to invoke the "CalculateSum" and "Print" methods

of "ProblemSolution".
Write a function:
void Solution(int N1, int N2)

that accepts two integers N1 and N2. The function should instantiate "ProblemSolution" object with N1 and N2 values and call "CalculateSum" and "Print" method by creating a pointer to the object of "ProblemSolution".

Input
12 5

Output
17
Assume that,

N1, N2 and sum are integers within the range [-1,000,000,000 to 1,000,000,000].
Given Code to work with:

#include
#include
#include
using namespace std;

class ProblemSolution{
int N1,N2,result;
public:
ProblemSolution(int N1, int N2){
Computers and Technology
1 answer:
faltersainse [42]3 years ago
3 0

Answer:

#include <iostream>

using namespace std;

class  ProblemSolution {

private:

int num1, num2;

public:

ProblemSolution(int n1, int n2) {

 num1 = n1;

 num2 = n2;

}

int calculateSum() {

 int sum = 0;

 sum = num1 + num2;

 return sum;

}

void printSum() {

 // calculateSum will return sum value that will be printed here

 cout <<"Sum = "<< calculateSum();

}

~ProblemSolution() {

 cout << "\nDestructor is called " << endl;

};

};

int main() {

int a, b;

cout << "Enter a: ";

cin >> a;

cout << "Enter b: ";

cin >> b;

// Initiallizing object pointer of type ProblemSolution

ProblemSolution *objPtr = new ProblemSolution(a,b);

// printing Sum

objPtr->printSum();

// delete objPtr to relaease heap memory :important

delete objPtr;

return 0;

}

Explanation:

we will initialize  a pointer "objPtr" and initallize the constructor by passing 2 values a and b followed by the keyword  "new". the keyword "new" allocates memory in the heap. we can access class member functions using arrow "->". it is important to delete objPtr at the end of the program so that the heap memory can be freed to avoid memory leakage problems.  

You might be interested in
In information systems, _____ is information from a system that is used to make changes to input or processing activities.
Tom [10]

Answer:

"Feedback" is the correct answer for the above question.

Explanation:

  • Feedback is used in any information system or any communication system to tells that any process is doing in the right direction.
  • It is used in communication channels to tell the sender that the message is received by the receiver.
  • It is a type of message which is sent by the user to the system that he gets the correct or wrong output by that system.
  • The above question asked about the term which is used in the information system which suggests changing the processing activity. This is known as feedback which is described above.
6 0
3 years ago
Suppose users share a 1-Gbps link. Also, suppose each user requires 200 Mbps when transmitting, but each user only transmits 30
V125BC [204]

Answer:

The answer is "5 users and 1 block".

Explanation:

In Option a:

Bandwidth total = 1-Gbps \times 1000

                          = 1,000 \ Mbps      

Any User Requirement = 200 \ Mbps

The method for calculating the number of approved users also is:  

Now, calculate the price of each person for overall bandwidth and demands,  

\text{Sponsored user amount} = \frac{\text{Bandwidth total}}{\text{Each user's requirement}}

                                     =\frac{1000}{200}\\\\=\frac{10}{2}\\\\= 5 \ users

In Option b:

\text{blocking probability} = \frac{link}{\text{1-Gbps} = 10^9 \frac{bits}{sec}}

\ let = 0.05 = \frac{100}{20} \\\\\text{blocking probability} = \frac{ 200 \times 10^6}{\frac{100}{20}}

                                = \frac{ 200 \times 10^6 \times 20 }{100}\\\\= \frac{ 2 \times 10^6 \times 20 }{1}\\\\= 40 \times 10^6 \\\\

mean user = 25 \times \frac{1}{20} \\\\

                  = 1.25

max user = \frac{10^9}{40 \times 10^6} \\\\

                = \frac{10^9}{4 \times 10^7} \\\\ = \frac{10^2}{4} \\\\ = \frac{100}{4} \\\\= 25 \\\\ =\ \ 1 \ \ block \\\\

3 0
3 years ago
Which ribbon tab is not a default in Outlook 2016's main interface?
IRISSAK [1]

Answer:

view

Explanation:

i just know it

8 0
3 years ago
Read 2 more answers
The destructor automatically executes when the class object goes out of ____.
Tema [17]

Answer:

scope    

Explanation:

Destructor is a member function and it call automatically when the class object goes out of scope.

Out of scope means, the program exit, function end etc.

Destructor name must be same as class name and it has no return type.

syntax:

~class_name() { };

For example:

class xyz{

  xyz(){

        print(constructor);

   }

~xyz(){

        print(destructor);

   }

}

int main(){

    xyz num;

   

}//end program

when the object is create the constructor will called and when the program end destructor will call automatically.

4 0
3 years ago
What is a biometric scanner?
Lisa [10]
<span>an electronic device used to determine a person's identity by detecting and matching the person's physical features, such as fingerprints or the eyes, to a database</span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • Your health insurance company gives you a discount if you wear a fitness-tracking bracelet. After wearing it for a few months, y
    5·1 answer
  • To keep from overwriting existing fields with your Lookup you can use the ____________ clause.
    14·2 answers
  • Which is a real-world example of a procedure?
    11·1 answer
  • Demographics refers to
    7·1 answer
  • Write a formula that would return a TRUE result if the sum of the first five numbers in a column of data are negative
    7·1 answer
  • Clasifica los documentos comerciales en activo, pasivo o patrimonial para cada operacion:
    14·1 answer
  • Computer programming 3
    13·1 answer
  • Any looping construct can be nested inside another loop is known as
    11·1 answer
  • Mention the usage of crop concept in ms-word​
    13·2 answers
  • Why would you browse by entering a URL rather than use a link in a Web page
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!