Concept explainers
Assume the definition of class houseType as given in Exercise 11. Answer the following questions. (1, 2, 3, 5, 7)
Write the definition of the member function set so that private members are set according to the parameters.
Write the definition of the member function print that prints the values of the data members.
Write the definition of the constructor of the class houseType so that the private member variables are initialized to according to the parameters.
Write a C++ statement that prints the value of the object newHouse.
Write a C + + statement that declares an object house of type newHouse, and initializes the member variables of house to “Ranch”, 3, 2, 2, 2005, 1300, 185000, and 3600.0, respectively.
Which function members are accessors and which are mutators?
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
- PROBLEM COPY CONSTRUCTOR Copy Constructor Ebox team created a course for their employees and wanted to provide the same course for the faculties in one of the colleges. So they decided to replicate the course using a copy constructor. Write a program to display the given details with the normal constructor and the copy constructor. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Course has the following public data members. Data Type string string string string Variable Name course_hame sessionname1 sessionname2 sessionname3 Define a CO the came order 2e e Type here to searcharrow_forwardPrototype and functional call pleasearrow_forwardC++ program: In this exercise, you will design the class memberType. Each object of memberType can hold the name of a person, member ID, number of books bought, and amount spent. Include the member functions to perform the various operations on the objects of memberType—for example, modify, set, and show a person’s name. Similarly, up-date, modify, and show the number of books bought and the amount spent. Add the appropriate constructors. Write the definitions of the member functions of memberType. Write a program to test various operations of your class memberType. File memberData.txt: 410John Williams0020Lisa Berry235.5030Ron Brown10255.6840Jessey Smith00 The program will be checked by criterias as below: The program can initialize objects of type memberType without error. memberType's isMemberID indicates which member object is assigned the provided ID. memberType's getBooksPurchased returns the number of books purchased. memberType's getTotalAmountSpent returns the total amount…arrow_forward
- C++ please help me answer this question I will give you a good rating Thank you! Choose the correct answer to the question. Which of these is not a property of a class? Member variables and member functions may be public, protected, or private. A class may not use another class as the type for a member variable. The name of a member function for a class may be overloaded just like the name of an ordinary function. A function may have formal parameters whose types are classes. A function may return an object of a class. Choose the correct answer to the question.The copy constructor is executed... When one object is assigned to another object at its creation When objects are passed to a function using call by value When the function returns an object reference.b, c only a, b onlyAll of the abovearrow_forwardAll data members must be declared as “private”•No global variable canbe declared and used•Methods within the classand the requested functionscannot have “cin” or “cout” but it should make use of parameters and return value instead.•“cin” and “cout” should be done in main() or any testing functions•Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly. Define a new “changePassword” function that accepts 3 parameters:o A vector of User object pointerso User ID of the account to be changedo New passwordIt will return true if it can find that User object with the same user ID andchange the password for that User and false otherwise.Show how this function is being called and returning proper information.You can assume that the user ID is unique in the given vector object. Do not use mallocarrow_forwardc++arrow_forward
- Lab02-03. Reference Type C++ : Write a program that defines an object of type double called myDouble. Define an object of reference type called myReference and initialize it with myDouble. Change the value of myReference. Print the object value using both the reference and the original variable. Change the value of myDouble. Print the value of both objects.arrow_forwardPS: see image for question.arrow_forwardC++ :: 14. assume the definition of class temporary as given in exercise 13. answer the following questions. (1, 2, 3, 5, 7) a. write the definition of the member function set so that the instance variables are initialized according to the parameters. b. write the definition of the member function manipulate that returns a decimal number as follows: if the value of description is "rectangle", it returns first * second; if the value of description is "circle", it returns the area of the circle with radius first; if the value of description is "sphere", it returns the volume of the sphere with radius first; if the value of description is "cylinder", it returns the volume of the cylinder with radius first and height second; otherwise it returns the value -1. c. write the definition of the function print to print the values of instance variables and the values returned by the function manipulate. for example, if description = "rectangle", first = 8.5, and second = 5, it should print:…arrow_forward
- Problem Write a C++ program that declares a class named Point to model a point. A point is represented by its coordinates x and y. Separate the class definition from declaration within the same file. Do the following tasks to accomplish the program. 1. Define several constructors for the class as follows. Use constructor initializer and default arguments whenever possible. a. A constructor that accepts two parameters to initialize the coordinates x and y respectively. b. A copy constructor that accepts another Point object. Use a constructor initializer to invoke constructor (a) c. A default constructor that sets the coordinates x and y to 0. Use a constructor initializer to invoke any of the above constructor s. 2. Define a constant method named print() that prints the coordinates x and y of the point. Explain what is a constant method and what is used for? Why is this method better to be declared as a constant method? Write your answers as comments in the program. 3. Define a method…arrow_forwardImportant requirements for all questions: • All data members must be declared as “private” • No global variable is allowed to be declared and used • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead. • “cin” and “cout” should be done in main() or any testing functions • Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly.arrow_forwardImportant requirements for all questions: • All data members must be declared as “private” • No global variable is allowed to be declared and used • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead. • “cin” and “cout” should be done in main() or any testing functions • Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr