Write the header file Widget.h for the Widget class. The Widget class has three
ID: 3635808 • Letter: W
Question
Write the header file Widget.h for the Widget class.The Widget class has three data members:
description : data member of type stringprice : data member of type doublewidget_count : static data member of type intThe Widget class has a constructor that initializes each non-static data member.
The Widget class has three additional member functions:
getDescription : no parameters, returns description computeTotalPrice : number of widgets parameter, computes and returns the total price for the specified number of widgets, Widget object is not modifiedincrementWidgetCount : static member function, no parameters, adds 1 to widget_count, returns nothing Any member functions that can be declared const should be declared const.
Include any necessary preprocessor directives and header file include statements.
Do not provide the implementation of the member functions.
Explanation / Answer
Dear, Here is the code #ifndef WIDGET_H #define WIDGET_H class Widget { string description; double price; static int widget_count=0; public:Widget(string des,double pr,int count) { description=des; price=pr; } string getDescription(); double computeTotalPrice(int count); static void modifiedincrementWidgetCount()const; }; defnition of class member functions string getDescription() { return des; } double computeTotalPrice(int count) { return price*count; } static void modifiedincrementWidgetCount()const { widget_count=widget_count+1; } Hope this wil help you..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.