Mark the following statements as true or false.
The member variables of a class must be of the same type. (1)
The member functions of a class must be public. (2)
A class can have more than one constructor. (5)
A class can have more than one destructor. (5)
Both constructors and destructors can have parameters. (5)
The member variables of a class are the variables declared in the definition of the class.
The member variables of a class need not be of the same type. Hence, the given statement is “False”.
Explanation of Solution
The member variables of a class need not be of the same type and can be any valid data type of C++ or any user defined type.
Want to see more full solutions like this?
Chapter 10 Solutions
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Malik's C++ Programming: From Problem Analysis To Program Design, 8th (mindtap Course List)
- Assume the definition of class houseType as given in Exercise 11. Answer the following questions. (1, 2, 3, 5, 7) a. Write the definition of the member function set so that private members are set according to the parameters. b. Write the definition of the member function print that prints the values of the data members. c. Write the definition of the constructor of the class houseType so that the private member variables are initialized to according to the parameters. d. Write a C++ statement that prints the value of the object newHouse. e. 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. f. Which function members are accessors and which are mutators?arrow_forwardexplain why you would define a class as staticarrow_forwardNutritional information (classes/constructors) PYTHON ONLY Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's10.034.02.01.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is:…arrow_forward
- It is possible for a class to have more than one constructor.A) This is correct. B) The answer is False.arrow_forwardCruise Recreational Activities Example Recreational activities include things like aerobics, shuffle board, and swimming. Each activity is identified by an activity code and includes other information such as description. Classes are offered for each activity. A class is uniquely identified by a combination of the activity code and the day/time at which it is held. It is assumed that a specific class will never be offered for the same activity at the same day and time, although it could be offered on a different day and/or time. Other information about a class includes the enrollment limit and the current enrollment count. A class will never include more than one activity. A passenger can sign up for a class as long as there is sufficient room in the class. Passengers are identified by a unique passenger number. Other information stored about passengers includes name, address, and age. Passengers have no limit on the number and type of classes they can sign up for. When they…arrow_forwardJust what are "static members" of a class? When and how should you use them, exactly?arrow_forward
- An organization has two types of employees: regular and adhoc. Regular employees get a salary which is basic + DA + HRA where DA is 10% of basic and HRA is 30% of basic. Adhoc employees are daily wagers who get a salary which is equal to Number * Wage (i) Define the classes shown in the following class hierarchy diagram: Employee name eno salary () Regular Adhoc wage пnber days (int n) salary O Basic salary ()arrow_forwardUse c# programming languagearrow_forwardCreate the class diagram and write the pseudocode for a program that will process the following attributes: studentNumber, studentName, grade, and status (will hold "Pass" or "Fail"). Name your class as "Student" and your object as "aStudent". The attributes and functions must be declared as private and public respectively. Each attribute must have its own member function when assigning values and the values must be passed from the main program as arguments. Declare one more member function to display the values of all attributes. Class Diagram Grading Criteria Pseudocode Grading Criteria Correct class name. Correct class name. 10 All attributes were declared as private 10 All attributes were declared as private. 10 Member functions were declared as public. Correct sequence. Member functions accepted values from the main program. 10 Member functions were declared as public 10 10 10 Correct sequence. Member functions accepted values from the main program Statements are structured…arrow_forward
- Regarding Object Oriented Programming, Classes contain: Choose all that apply A.) Member variables B.) Member Methods C.) Constructors D.) Inhereted typesarrow_forwardIn order to extend a class, the new class should have access to all the data and inner workings of the parent class. True Falsearrow_forward(a)Definition of class Vehicle Instance variables: year that holds the year of vehicle (int) make that holds the make of vehicle (string) Methods: a second constructor that accepts the Vehicle's year and the make as arguments. These values should be assigned to the object's instance variables: year and make. Accessor methods (getYear() and getMake()) that get the values of instance variables Mutator methods (setYear(int) and setMake(String)) that set the values of instance variables. toString() should return a string with the values of instance variables of vehicle object equals() should accept a vehicle object reference as argument and return true if all instance variables of calling object are same values as those of passed vehicle object, respectively, or false otherwise. brake() should do nothing (i.e., empty body). This method is for polymorphism to call appropriate brake() method of subclass. (b)Definition of class Car, which is a…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage