please show work and it\'s one question but it have parts please solve all the p
ID: 3915746 • Letter: P
Question
please show work and it's one question but it have parts please solve all the parts
Structor: A. Alfano Hills NEATNESS COUNTS...ILLEGIBLE means INCORRECT! PLEASE P Note:. Please work on this sheet and place the LETTER ONLY of the correcet 4) Given the following class: class bookType public: (Yes; NAME on ALL PAGES) T CLEARLY. void setBookTitle(string s); void setBookISBN(string ISBN); void setBookPrice(double cost); void setCopiesInStock(int noOfCopies): //sets the bookTitle to s //sets the private member bookISBN to the parameter //sets the private member bookPrice to cost //sets the private member copiesInStock to noorCopies void printInfo0 const; l/copiesInStock //prints the bookTitle, bookISBN, the bookPrice and the string getBookISBNO const; double getBookPrice0 const; int showQuantity InStock0 const; //returns the bookISBN //returns the bookPrice Wreturns the quantity in stock void updateQuantity(int addBooks); value plus the parameter sent //to this function private: //adds addBooks to the quantity InStock, so that the quantity /in stock now has it original string bookName; string bookISBN; double price; int quantity (1) One is the DEFAULT CONSTRUCTOR (2) The other (#2) is a Constructor that takesfour parameters and sets the INITIAL You want to add TWO CONSTRUCTORS for the class above. values for the bookName (set to blank), bookISBN (set to blank), price (set to zero), and quantity parameters(set to zero). Page 7 of 13Explanation / Answer
The first constructor is the default constructor which takes no parameters. The second one is a parametrized constructor which takes 4 parameters namely bookName, ISBN number, price and quantity and calls the corresponding setter methods to initialize them.
Also the scope resolution operator "::" is used to define a method outside of class body and is not required in the class definition itself.
Hence the correct answer would be (A).
B) and C) use scope resolution inside the class definition itself and D) does not accept 4 parameters as required.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.