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
Write an application named SumInts that allows the user to enter any number of integers continuously until the user enters 999.
Nana76 [90]

Answer:

import java.util.Scanner;

public class num10 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter the numbers to add up. enter 999 to stop");

       int num = in.nextInt();

       int sum = 0;

       while (num!=999){

           sum = sum+num;

           System.out.println("Enter the next number");

           num = in.nextInt();

       }

       System.out.println("The sum is: "+sum);

   }

}

Explanation:

The application is implemented in Java

A while loop is used to continously prompt user for inputs. The condition of the while loop is  while (num!=999)

When the number 999 is entered, it displays the sum which is initialized to 0

4 0
3 years ago
In vehicles equipped with ABS, the driver's foot must remain firmly on the ... to activate the ABS.
GREYUIT [131]
ABS is activated when the computer detects the wheel[s] are decellarating too quickly. It then pumps the brakes about 15 times a second. People can't pump the brakes anywhere near that fast, so it's better that the driver just keep the brake pedal depressed and let the machine take care of it.
5 0
3 years ago
pen the PT Activity. Perform the tasks in the activity instructions and then answer the question. Which event will take place if
zysi [14]

Answer:

Packets with unknown source addresses will be dropped.

Explanation:

This question is incomplete, we must add the number "1" in Fa0/1.

Which event will take place if there is a port security violation on switch S1 interface Fa0/1?

There are four options:

- A notification is sent.

- A syslog message is logged.

-The interface will go into error-disabled state.

- Packets with unknown source addresses will be dropped.

In this specific example, we have configured a security protection mode, if there is an unknown MAC address,  every package will be dropped.

We can configure in our switch with different Mac address, if there is not a MAC address in our configuration, the security mode will active, and we could receive any package.

5 0
4 years ago
Which CSS property configures the font typeface?
Vitek1552 [10]
The answer to this is font-family.
Example of usage:
```
<em>#headerFont{</em>
<em>   font-family: Times New Roman;</em>
<em>}
</em>
```
You can put your font name in quotes <em>(eg: "Ariel")</em> but it's not always necessary- but it is a good practice to get into because it helps to avoid certain fonts not being able to show up. Please note there are some fonts that will not work in certain browsers.

   If you choose a custom font ether you made or you downloaded, unless you have the font itself saved into your code, unless the user has that font on their end, they will <em>not</em> see it- this is where backup fonts are helpful until or using universal ones; at least until you learn how to integrate the font fully into your website.
5 0
3 years ago
8. When requesting a review of a denied claim, it is required to send a _______________ with the claim.
liq [111]
I'd say an appeal letter.

An appeal letter should be sent with the claim to request for review of an insurance claim that has been denied or underpaid by an insurance company. An appeal is important because it lets the insurance company know that you disagree with the decisions they have issued



4 0
3 years ago
Other questions:
  • When you right-click certain areas of the Word or other Office app windows, a command menu will appear. Group of answer choices
    13·1 answer
  • We are continuously sending and receiving messages that may change midstream. This illustrates that____________.
    15·1 answer
  • The design strategy that starts with a global view of the entire problem and breaks the problem down into smaller, more manageab
    8·1 answer
  • En que se diferencia el software y el hardware
    7·2 answers
  • Declare an ArrayList of Strings. Add eight names to the collection. Output the Strings onto the console using the enhanced for l
    9·1 answer
  • Microsoft word 2010 lab 6-1
    7·2 answers
  • Insertion point shows where the typed text will appear.
    5·1 answer
  • I recorded a video on my windows PC, but when i tried to play it i got this message:
    6·2 answers
  • Pleaseee help me with the typical situations of the icons(i already know for words but I have no idea for giving the situations
    5·1 answer
  • Any mobile devices contain a(n) ___ and gyroscope that can sense even the smallest movements.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!