Concept explainers
Suppose your
class YourClass { public: YourClass(int newInfo, char moreNewInfo); YourClass(); void doStuff(); private: int information; char moreInformation; }; |
Which of the following are legal?
YourClass anObject(42, 'A'); YourClass anotherObject; YourClass yetAnotherObject(); anObject = YourClass(99, 'B'); anObject = YourClass(); anObject = YourClass; |
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out With Visual Basic (7th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with C++: Early Objects
Modern Database Management (12th Edition)
- In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extclockType from the class clockType by adding a member variable to store the time zone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write a test program to test your class.arrow_forwardUsing classes, design an online address book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates. Your program should be able to handle a maximum of 500 entries. Define a class addressType that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables. Define a class extPersonType using the class personType (as defined in Example 10-10, Chapter 10), the class dateType (as designed in this chapters Programming Exercise 2), and the class addressType. Add a member variable to this class to classify the person as a family member, friend, or business associate. Also, add a member variable to store the phone number. Add (or override) the functions to print and store the appropriate information. Use constructors to automatically initialize the member variables. Define the class addressBookType using the previously defined classes. An object of the type addressBookType should be able to process a maximum of 500 entries. The program should perform the following operations: Load the data into the address book from a disk. Sort the address book by last name. Search for a person by last name. Print the address, phone number, and date of birth (if it exists) of a given person. Print the names of the people whose birthdays are in a given month. Print the names of all the people between two last names. Depending on the users request, print the names of all family members, friends, or business associates.arrow_forwardCreate a class named 'Member' having the following members using C++:Data members 1 - Name 2 - Age 3 - Phone number 4 - Address 5 - Salary It also has a method named 'printSalary' which prints the salary of the members. Two classes 'Employee' and 'Manager' inherits the 'Member' class. The 'Employee' and 'Manager' classes have data members 'specialization' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a manager by making an object of both of these classes and print the same.arrow_forward
- If Lawyer is a subclass of superclass Employee. There is a user-defined constructor Employee(int age), define the constructor in the Lawyer class that would use the constructor Employee(int age) in the superclassarrow_forwardCreate an abstract class Product with following Properties Price (Decimal), Code (string), Description (string) Create an interface ISellable with the following Method sell that takes the count of the products to sell and returns the cost public decimal sell(int count); Create a concrete class Book that Inherits from class Product and implements interface ISellable Has additional Property Author (string) Add a constructor with parameters, and ToString method to display all of data of class Book Similarly, create anot concrete class Software that Inherits from class Product and implements interface ISellable Has additional Property Version (string) Add a constructor with parameters, and ToString method to display all of data of the class Software Finally, write a client code (main program) that will utilize the class and interface hierarchy you created. Create two Book objects for the following books C# 8.0 in a Nutshell, with price $50.99 and with ISBN…arrow_forwardUsing classes and arrays, the team will develop a set of functions for an onlineshopping system. The system is represented by the following structure:1- Class Item having the following private attributes: (ID, name, quantity, price) andthe following public methods:- Constructors (default, parameterized, and copy)- Setters & Getters- Operator overloading for the ==, +=,-=, >> and << operators Note that the ID member variable is not entered or read from the user. It isautomatically set by the class as a serial ID starting with the first item of ID 1 andincrementing with every new object.2- Class Seller having the following private attributes: (name, email, items,maxItems),where items is a dynamic array of objects of type Item with the size maxItems. Theclass has the following public methods:- Constructor (parameterized)- Operator overloading for the insertion << operators- Add An Item.- This will take an Item object as a parameter:- If the item already exists in the…arrow_forward
- Given the following class declaration (with prototypes): class Carpet { private: double pricePerSqYd; public: Carpet(); void setPricePerYd(double p); void setDimensions(double l, double w); double getTotalPrice() const; }; Assume the class Carpet has been implemented. Assume the class Rectangle has been implemented. Rewrite the entire Carpet class declaration and add a member variable named size which is an instance of the Rectangle class.arrow_forwardJava Program There is a company who known for its courier service. They have service namely Basic, TwoDayPackage and OvernightPackage.Create a base class Package has the following: It has three attributes type Person sender, Person receiver, int weight Encapsulate the fields Override toString and Equals of the Object class Define calculateCost with a return type of double as abstract Create the following constructors- default constructor- constructor that accepts attribute sender, receiver, and weight- constructor that accepts two name, two address, two phone numbers and weight NOTE: Person has the following attributes: String name, String address, and String phone numberarrow_forwardUsing classes and arrays, the team will develop a set of functions for an online shopping system. The system is represented by the following structure: 1- Class Item having the following private attributes: (ID, name, quantity, price) and the following public methods:- Constructors (default, parameterized, and copy)- Setters & Getters- Operator overloading for the ==, +=,-=, >> and << operatorsNote that the ID member variable is not entered or read from the user. It is automatically set by the class as a serial ID starting with the first item of ID 1 and incrementing with every new object.2- Class Seller having the following private attributes: (name, email, items,maxItems), where items is a dynamic array of objects of type Item with the size maxItems. The class has the following public methods:- Constructor (parameterized)- Operator overloading for the insertion << operators- Add An Item.- This will take an Item object as a parameter:- If the item already exists…arrow_forward
- Create a class Car, which contains • Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (of integer type)• A no-argument constructor to initialize all data members with default values• A parameterized constructor to initialize all data members with user-defined values• Three setter functions to set values for all data members individually• Three getter function to get value of all data members individually• A member function setSpeed( ) // takes integer argument for setting speedDerive a class named Convertible that contains• A data member top (of Boolean type)• A no-argument constructor to assign default value as “false” to top• A four argument constructor to assign values to all data-members i.e. carName, ignition,currentSpeed and top.• A setter to set the top data member up• A function named show() that displays all data member values of invoking objectWrite a main() function that instantiates objects of Convertible class and test the…arrow_forwardCreate a class Car, which contains • Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (of integer type) • A no-argument constructor to initialize all data members with default values • A parameterized constructor to initialize all data members with user-defined values• Three setter functions to set values for all data members individually• Three getter function to get value of all data members individually• A member function setSpeed( ) // takes integer argument for setting speedDerive a class named Convertible that contains • A data member top (of Boolean type) • A no-argument constructor to assign default value as “false” to top• A four argument constructor to assign values to all data-members i.e. carName, ignition, currentSpeed and top.• A setter to set the top data member up • A function named show() that displays all data member values of invoking objectWrite a main() function that instantiates objects of Convertible class and test the…arrow_forwardDesign a generic class to hold the following information about a bank account. - Balance, number of deposits this month, number of withdrawals, annual interest rate, monthly service charges. The class should have the following member functions constructor: accepts arguments for the balance and annual interest rate deposit: A virtual function that accepts an argument for the amount of the deposit. The function should add the argument to the account balance. It should also increment the variable holding the number of deposits. withdraw: A virtual function that accepts an argument for the amount of the deposit. The function should subtract the argument to the account balance. It should also increment the variable holding the number of deposits. calcInt: A virtual function that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed by the following formulas: Monthly Interest Rate = (Annual Interest Rate /12)…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,