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 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
