Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following program generates an error. Why? #include iostream #include < string #include Shopping. cpp using namespace std; int main ( ) { int

The following program generates an error. Why?
#include iostream
#include < string
#include "Shopping. cpp"
using namespace std;
int main (){
int num1; int num2; cin >> num; cin >> num2; if (num1> num2)
cout numl " is greater"< endl
else
cout << num2<" is greater" endl;
return 0;
Only h files can be included, hence including Shopping.cpp is invalid.
main) must define a Shopping object, since the Shopping class is included.
No strings are used in the program, so the include statement for string would generate an error.
The variables num1 and num2 should be declared in a class and accessed through functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago