I have been given an assignment from my uni to create a bank where im to have customers with multiple accounts and different account types, also then add other things like loans etc.
Im having problems getting a linked list to work with the class objects. my aim is to store all the customers details, and account details in the class objects then list all the customers in the linked list instead of using something like an array as we get more marks for using linked lists.
so far i have managed to get it so the customer can be created and pointing to just one account. but i am stuggling with understanding how im to then create the linked list so it connects to the class object.
these are some bits of the code which i have so far:
with this im not sure if im doing it the correct way, but am i to create the objects then pass in the refference to it, which is then stored in the linked list?
CustomerList.cpp
#include "CustomerList.h"
#include <iostream>
using namespace std ;
CustomerList::CustomerList()
{
front = back = 0;
}
bool CustomerList::isEmpty()
{
return front == 0;
}
void CustomerList::addCustomer(Customer *tempCustomer)
{
Node* insert = new Node(tempCustomer);
if (front == 0)
{
back = front = insert;
}
else
{
back-> next = insert ;
back = back -> next ;
}
}
CustomerList::removeCustomer()
{
Customer tempCustomer; Node* temp;
if (front != 0)
{
tempCustomer = front -> customerRef;
temp = front;
front = front -> next ;
delete temp ;
if (front == 0) back = 0;
return tempCustomer;
}
else return '\0';
}
CustomerList::~CustomerList()
{
Node * temp;
while(front != 0)
{
temp = front;
front = front -> next;
delete temp;
}
}
void CustomerList::print()
{
Node * temp = front;
if (temp != 0 )
{
while (temp != 0)
{
cout << temp -> customerRef.getName() ;
temp = temp -> next;
}
}
else cout << "empty";
cout << endl;
}
LP cores are MUCH lower power than Efficiency cores. Efficiency cores never really lived up to their name, but they did add a meaningful amount of performance in multithreaded loads, so Intel isn't going to remove them.
I don't usually say this, but WTF Microsoft?! Do you hate your customers, or do you just really not care at all? Windows Hello is one of the useful Windows features, and now you're effing it up.
Question
soil
I have been given an assignment from my uni to create a bank where im to have customers with multiple accounts and different account types, also then add other things like loans etc.
Im having problems getting a linked list to work with the class objects. my aim is to store all the customers details, and account details in the class objects then list all the customers in the linked list instead of using something like an array as we get more marks for using linked lists.
so far i have managed to get it so the customer can be created and pointing to just one account. but i am stuggling with understanding how im to then create the linked list so it connects to the class object.
these are some bits of the code which i have so far:
AssignmentBank.cpp (main)
with this im not sure if im doing it the correct way, but am i to create the objects then pass in the refference to it, which is then stored in the linked list?
CustomerList.cpp
CustomerList.h
any help at all would be useful.
I have gone to extra classes at uni and asked lecturers over and over but they dont seem to be helping me much.
Link to comment
https://www.neowin.net/forum/topic/955220-c-linked-list-and-objects/Share on other sites
7 answers to this question
Recommended Posts