show all the work CSC 211- SUMMER 2013s -lestructors A.Alfano H Name NEATNESS {
ID: 3915668 • Letter: S
Question
show all the work
CSC 211- SUMMER 2013s -lestructors A.Alfano H Name NEATNESS { OUNTS.JL? EGIISLF moins INCORRECT! Pl.E ASE TRACE means ShoW Note Please work on this sheet and place the LE.TTER ONLYfte Yes: NAME on ALL PAGES cerrect sse er 4) Gives thw following class lass book Type publie void setBook Ticleistring si ts the bookTine t Wsets the private member bookIS8S to the parameder sets the private member bookPrice to cro hets the private member copiesleStock to ?.nrcepis Wset s volid vesls void seeCopies laStocktint noOC opless soid priatinfu) const; string getBookISBNO ceast; double gecBookPrice)0 csast; iat show Quantity la Stock) esast; prints the boek Title, bsukISBN, the boakPrice and the MeopiesinSteck relurss the baokISEN Wreturas the bookPrice üretarns the qeantity in stock void updateQuantity lint addliooks)s value plus the parameter sent Pto this functie private: Wadds addBouks to the quantitylaStock, so that the qeantity ia stock new has it sriginal string bookName string bookISHN double price nt quantity (1) One is the DEFAULT CONSTRUCTOR (2) The other (N2) is a Coastractor that talkes foar parameters and sets the INITIAL You wast to add TWO CONSTRUCTORS for the class above. valaes for the book Name (set to blank, bookIS&N; (set to Mank), price (set to zeroj and guamüny parumerersfset to zero). Page 7 of 13Explanation / Answer
Ans: a)
bookType(); //default constructor
bookType(string,string,double,int);//parameterised constructor
Add the below lines if you want to write a default consructor and
parameterised constructor to class bookType.
While creating a object it will call these constructors depending on the
type you create a object.
Please include these definitions in class definition under public : access specifier or else
you will get error while creating object of bookType
public:
bookType(){ //default constructor
bookName="";
bookISBN="";
price=0;
quantity=0;
}
//If we write bookType book in main ,it will call above constructor and intialise the object with above values
bookType(string book,string ISBN,double cost,int num){//parameterised constructor
bookName=book;
bookISBN=ISBN;
price=cost;
quantity=num;
}
//If we call bookType book("RICH DAD","USA",30,10);
//It will create object book by calling the above parameterised constructor with default values.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.