![]() How to use a preprocessor wrapper to prevent multiple definition errors caused by including more than one copy of a header file in a source-code file.OBJECTIVES In this chapter you’ll learn: This above all: to thine own self be true.Don’t be “consistent,” but be simply true.Test that all your member functions work properly.My object all sublime I shall achieve in time. Now write a driver program to test your rntegerset class. Provide an additional constructor that receives an array of integers and the size of that array and uses the array to initialize a set object. Provide an isEqualto member function that determines whether two sets are equal. Print only those elements that are present in the set (i.e., their position in the array has a value of Provide a printset member function that prints a set as a list of numbers separated by spaces. Provide a deleteElement member function that deletes integer $m$ (by setting al $m$ ) to 0 ). Provide an insertElement member function that inserts a new integer $k$ into a set (by setting al $k$ ) to 1 ). Provide an intersectionofsets member function which creates a third set which is the set-theoretic intersection of two existing sets (i.e., an element of the third set's array is set to 0 if that element is 0 in either or both of the existing sets, and an element of the third set's array is set to 1 if that element is 1 in each of the existing sets). For example, provide a unionofsets member function that creates a third set that is the settheoretic union of two existing sets (i.e., an element of the third set's array is set to 1 if that element is 1 in either or both of the existing sets, and an element of the third set's array is set to 0 if that element is 0 in each of the existing sets). Provide member functions for the common set operations. The default constructor initializes a set to the socalled "empty set," i.e., a set whose array representation contains all zeros. Array element al $j$ ] is 0 if integer $j$ is not in the set. Array element al i 1 is 1 if integer $i$ is in the set. $ A set is represented internally as an array of ones and zeros. Then set the annualtnterestRate to 4 percent, calculate the next month's interest and print the new balances for each of the savers.Ĭreate class Integerset for which each object can hold integers in the range 0 through $100. Then calculate the monthly interest and print the new balances for each of the savers. Instantiate two different objects of class SavingsAccount, saver1 and saver2, with balances of $\$ 2000.00$ and $\$ 3000.00,$ respectively. Write a driver program to test class SavingsAccount. Provide a static member function modifyInterestrate that sets the static annualtnterestrate to a new value. Provide member function calculateMonthlyInterest that calculates the monthly interest by multiplying the balance by annualinterestRate divided by $12 $ this interest should be added to savingsBalance. Each member of the class contains a private data member savingsBatance indicating the amount the saver currently has on deposit. ![]() Use a static data member annualinterestRate to store the annual interest rate for each of the savers. ![]() Member objects are constructed $\quad$ their enclosing class object.Ĭreate a savingsAccount class. If a member initializer is not provided for a member object of a class, the object's _ is called. The keyword _ specifies that an object or variable is not modifiable after it is initialized. $A(n)$ _ data member represents class-wide information. $A$ constant object must be _ it cannot be modified after it is created.Į. The $\quad$ operator dynamically allocates memory for an object of a specified type and returns a _ to that type.ĭ. The $\quad$ operator reclaims memory previously allocated by new.Ĭ. Member objects are constructed _ their enclosing class object. A member function should be declared static if it does not access _ class members. If a member initializer is not provided for a member object of a class. The keyword $\quad$ specifies that an object or variable is not modifiable after it is initialized. An object's non-static member functions have access to a "self pointer" to the object called the _ pointer. $A(n) \quad$ data member represents class-wide information.į. A constant object must be _ it cannot be modified after it is created.Į. The _ operator dynamically allocates memory for an object of a specified type and returns a _ to that type.ĭ. A nonmember function must be declared as a(n) _ of a class to have access to that class's private data members.Ĭ. _ must be used to initialize constant members of a class.ī. Fill in the blanks in each of the following:Ī.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |