Give a definition for the function with the following function declaration. The class BankAccount is defined in Display 10.5.
BankAccount newAccount(BankAccount oldAccount); //Precondition: oldAccount has previously been given a value //(that is, its member variables have been given values). //Returns the value for a new account that has a balance of zero //and the same interest rate as the oldAccount. |
For example, after this function is defined, a program could contain the following:
BankAccount account3, account4; account3.set(999, 99, 5.5); account4 = newAccount(account3); account4.output(cout); |
This would produce the following output:
Account balance $0.00 Interest rate 5.50% |
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Modern Database Management
Programming in C
Starting Out With Visual Basic (7th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Database Concepts (7th Edition)
- Suppose you are writing a class called Student that has two private members, std::string name and int perm. Write the function prototype (function declaration) only for a default constructor for Student. For full credit, include the semicolon that terminates the prototype, but do not write the body of the constructorarrow_forwardC++ Create a class Student that contains three members: roll no, name and mark, and three functions. Write a first inputStudent() function to get data of student class. Write a second getMark() function that returns a student’s mark. Write a third display() function that displays a student’s data. In a main() function, you need to declare 40 students and get data of all students by using inputStudent() function. And also use a pointer array to keep all students by mark greater than 50 and display the searching data of each student in that pointer array (Use the access operator -> to access a pointer points to member functions of the Student class).arrow_forwardobjective of the project: Implement a class address. An address has a house number street optional apartment number city state postal code. All member variables should be private and the member functions should be public. Implement two constructors: one with an apartment number one without an appartment number. Implement a print function that prints the address with the street on one line and the city, state, and postal code on the next line. Implement a member function comesBefore that tests whether one address comes before another when the addresses are compared by postal code. Returns false if both zipcodes are equal. Use the provided main.cpp to start with. The code creates three instances of the Address class (three objects) to test your class. Each object will utilize a different constructor. You will need to add the class definition and implementation. The comesBefore function assumes one address comes before another based on zip code alone. The test will also return…arrow_forward
- in c++ solve the following picture :arrow_forwardIN C++, create a class called Employee that includes three pieces of information as data members—a first name (type string), a last name (type string) and a monthly salary (type int). Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display each Employee’s yearly salary again.arrow_forwardWrite a simple C++ code I am a beginner. Subject: Object oriented programming Write a program that has an abstract base class. This class should have four member data variables and a pure virtual function. It should also have a method for setting the data variables. Derive a class from Base class and override a method in the base class. Write a main function that creates an object of derived class and sets the variables. Also write a top-level function that will take a parameter of type base class and return the value of the appropriate (override) function.arrow_forward
- Write a c++ program and explain with comments Create a class called Employee that includes attributes: empid, name, points, group, and avg with data types: “int”, “String”, “double”, “String”, and “double” respectively. Include a constructor with parameters: empid and name. Include another constructor to assign default values to the attributes. Include a function called addPoints that is used to add a given amount to the value of the attribute points. Include a function called upgradePoints that is used to increase the value of theattribute points by a given percentage. Include a function called removePoints that is used to reduce a given amount fromthe value of the attribute points. If the resultant value is negative then the value of the attribute should be set into zero. Include a function called computeGroup that assigns a value to the attribute groupbased on the value of the attribute points as given in the following table. Points Group points < 100 Silver 100…arrow_forwardc++arrow_forwardWrite a C++ code for the following question as quickly as you can. But please do the same as asked in the Question...arrow_forward
- Write a C++ program which creates a Class named as Person which represents a person by its Id (it must be unique), Name, Age, Address and Phone no. This class should have a parameterized constructor and destructor, the getter/setter functions and a showoutput () member function that prints the information of a Person object. PART A Create a Class named as Student that inherits publicly from class Person. A Student object is distinguished by the same attributes as a Person object plus his Course name, Room no (which is allocated to him) and GPA. This class should also have parameterized constructor and default destructor, setter/getter functions and a showoutput () member function. Your input should be similar to the following: *-*-*-**-*-*-*-*-*-*-*-*-* Enter Student's Information *-*-*-**-*-*-*-*-*-*-*-*-* Enter the Roll No: 1 Enter the Name of the Person:…arrow_forwardwrite a c++ programarrow_forwardwrite a c++ in which you vreate a class Point. This class have four member variables, a,b,c,d. Write the following member functions drawTriangle(int x, int y, int z ) and drawRectangle(int x, int y, int z, int a). Each function should calculate the length of lines and calculate circumference for each of the shape (triangle, rectangle). example triangle should calculate length of its three lines and then calculate circumference. such as, Note: the number of lines depends on the name of shape.void drawTriangle(int x, int y, int z ){int line 1 = x - y; // convert to positive value if line 1 is negativeint line 2 = y -z; int line 3 = z -x; cout<< the circumference of triangle is << //// here write formula to calculate circumference of triangle and display output of circumference}Write similar code for drawRectangle(int x, int y, int z, int a). write main function to callthese three functions to display output.b. write another function drawLine(int x, int y) in the above code.…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