Answered step by step
Verified Expert Solution
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 num; int num; cin num; cin num; if num num
cout numl is greater" endl
else
cout num is greater" endl;
return ;
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 num and num should be declared in a class and accessed through functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started