Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!