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
What option for deploying software to users provides a link to install an application within Control Panel's Programs and Featur
grin007 [14]

Answer:

This question is related to the  following options:

1. Published  - 2. Delegated -  3. Assigned  - 4. Mandated

And the option within Control Panel > Programs and Features > that includes a link to install an application is ; <em>"Published"</em>  thereby the answer would be <em>(</em><em>1.</em><em>)</em>

7 0
2 years ago
How all wheel drive works
faltersainse [42]
Yani cnm bu senin kararin istegidiin gibi davran Basarilar
8 0
3 years ago
you have been tasked with configuring a digital information station in the office's lobby. guests will be able to use the statio
REY [17]

The most important security consideration for the station is code signing. With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer.

With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer or mobile device with malware. Code signing has grown in importance for software developers and distributors as more software may be downloaded from the Internet.

Malware can be easily installed on a victim's computer by an attacker who poses as a trustworthy source. As long as users only download software that is regarded as safe by their operating system, code signing ensures that these types of assaults cannot happen.

Nowadays, the Operating System looks for the digital certificate produced through code signing when software is downloaded onto a computer to ensure the security of the software being installed. The user is informed and given the option to stop or continue the installation if no digital certificate is detected.

To know more about code signing click here:

brainly.com/question/28860592

#SPJ4

3 0
11 months ago
Discuss any five positive and five Negative impact<br>of ICT on society​
mojhsa [17]

Answer:

The technology of information communication has the capacity to transform society. It plays a key part and provides the infrastructure needed to achieve each of the United Nations Sustainable Development Goals. It also allows financial integration by m-commerce and lets people connect instantly to millions.

ICT has a particularly important impact on business. It allows people to exchange knowledge and advice immediately and establish a website or online shop at a low cost, thus reducing the obstacles to starting a business dramatically. As such, it is a major factor in change and the maturity of ICTs is strongly connected to economic growth.

Explanation:

Effects of ICT

As a human beings, we are always associated in our everyday life with many essential things. The use of ICT equipment in our lifestyle has simplified many time-consuming calculations and difficult tasks, and social contacts have been strengthened. ICT has affected life by enhancing the timely distribution of media information and improved home and workplace communications via social networking, e-mail, etc.

The quality of human life has been greatly improved by ICT. For example, it could take a few days for a letter to come to the recipient, but a single minute for an e-mail to reach. ICT offers a broader understanding and information for each facility  24 Hrs X 7 days. In the following, ICT affects different fields of daily living.

Positive Impacts of ICT:

  • As domestic and home businesses.
  • As social connectivity.
  • As E-learning/ As education
  • As for shopping/trading
  • As for banks
  • As a job/jobs

Negative Impacts of ICT:

  • Face-to-face interaction reduced.
  • Social Decoupling.
  • Physical activity/health issues reduced.
  • Cost.

4 0
2 years ago
Of the 3 primary electrical entites (voltage, current, and resistance )which is the result of the other two
sveta [45]

Answer: A

Explanation:cuz

5 0
3 years ago
Other questions:
  • How do you uninstall a program using the Control Panel?
    10·1 answer
  • As the demand for goods and services increases, job growth _____. a. increases b. decreases c. remains the same d. none of the a
    15·2 answers
  • Which of the following attack is a threat to confidentiality?
    10·1 answer
  • Andrew’s Complete Cameras offers its customers an interactive website to help them choose the best camera for their lifestyle. B
    5·1 answer
  • Why is manual coding the best way to learn HTML?
    11·1 answer
  • Why is it important to put the most specific case first? What types of errors does it help avoid?
    11·1 answer
  • Case Study/Scenario: First, Julio clicks Tools from the Chrome menu on the toolbar. Next, he looks for Manage Add-Ons but can no
    9·1 answer
  • 1.The hardware that allows data to be transmitted from a computer along a telephone line to another computer at the other end is
    12·1 answer
  • What is speaker?.....​
    13·1 answer
  • Pls answer i will give 20 points
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!