Answered step by step
Verified Expert Solution
Question
1 Approved Answer
So I am trying to follow the directions here: I am very confused as to how to implement structures, templates, and modify vector elements from
So I am trying to follow the directions here:
I am very confused as to how to implement structures, templates, and modify vector elements from a structure.
My code so far is:
Main:
function_file.cpp :
Header file:
So long story short, how exactly do I get this set up so that I can begin getting user input into first name, last name, and balance? (Account number generated randomly)
Create a vector of the bank accounts. Each element of the vector will have all the account information. To do this, you would have to use data structure. The keyword struct in C++ will make a data structure. Inside the data structure, you will define all of the account information The following is an example: struct Account int accountNumber; string lastName; string firstName; double account Balance; vector KAccount bankAccounts; The code snippet above defines data structure type Account and a vector name bankAccounts of type Account. Each element of the vector will have member accountNumber, lastName, firstName, and accountBalance. The vector should be defined in the main0function. This means that as long as the program running (the bank is operating), we have the list of bank accounts. This should not be the global variable. The program should be running until terminated by the user. In order to update the information of bank accounts in the vector. you would have to pass by reference to the functions. Another option is pass by pointer. You can explore this option if desiree. Because the data in the vector is of the special type, you have to make a template for the typename. Template allows you to write functions independent of the data type being passed to the functions. The example of a prototype function as follow: templateStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started