Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ question: I have a BankAccount class that has private member variables, string name, string id, and int balance. I made an array of 5

C++ question: I have a BankAccount class that has private member variables, string name, string id, and int balance. I made an array of 5 Bank Account objects that stored different names, bank balances, and id numbers, and I am required to allow a user to select whether they want to sort a bank account by name, id, or balance. I NEED to make a function using bubble sort code to sort through the array but I am not allowed to create a sort function for each member variable, what I mean by that is...if the user selects to sort by name or sort by balance, I can't call a sortbyname function or a sortbybalance function, I need to call the same sort function for all, but I don't know how to do this as I only know how to call a member function is I already know what function I need to access in the class, for example i would call the arr[i].getName to get the get name string to sort. But, I believe I am supposed to use templates, is there a way for me to call on the specific getter function for the variable option the user decides to sort the array with using templates that way I call upon the same sort function for the member function calls?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lean Audit The 20 Keys To World Class Operations A Health Check For Factory And Office

Authors: Joerg Muenzing

1st Edition

1514817829, 978-1514817827

More Books

Students also viewed these Accounting questions

Question

1. Plan in advance how and when you will test.

Answered: 1 week ago