Question: Provide the code for the header file. Note that you need to provide the declaration of the Product class and the print function (which is

 Provide the code for the header file. Note that you needto provide the declaration of the Product class and the print function

Provide the code for the header file. Note that you need to provide the declaration of the Product class and the print function (which is not a member function). product.h 1 #ifndef PRODUCT H 2 #define PRODUCT H 3 #include 4 #include 5 6 using namespace std; 7 8 class Product 9 { 10 public: 11 12 private: 13 14 }; 15 16 17 #endif product.cpp 1 #include 2. 3 using namespace std; 4 5 #include "product.h" 6 7 Product::Product(string product_name, double product_price) 8 { 9 name = product_name; 10 price = product_price; 11 } 12 13 string Product::get_name() const 14 { 15 return name; 16 } double Product::get_price() const { return price; } 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 void Product::adjust_price(double amount) { price = price - amount; } void print (ostream& out, const Product& p) { out setw(40) left p.get_name() right fixed setw(10) setprecision (2) p.get_price() #include "product.h" using namespace std; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 int main() { Product pl("Corn flakes", 3.95); Product p2("Bathroom cleaner", 7.95); P2. adjust_price(-0.75); print(cout, pl); print(cout, p2); return ; }

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!