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;
}
It has nothing to with Apple, Google, and Microsoft are trillion dollar companies that have near monopoly positions in certain markets segments huh? Hmmmm
Why are you 5 or 6 comments deep on this post? We get it you don't like Linux. Is the guy that knocked up your daughter and living at your house named Linux or something? LOL It's really weird how personal your comments are here. This is a tech site not everything posted here is going to be something that personally use and enjoy. Grow up and move on dude...
That's the standard? it needs to have top notch support for Windows games? LOL MacOS have never needed to do that. It's amazing how well Proton runs a lot of Windows games (some games actually better) and it's not appreciated by the causal user but Linux is never going to be for the hardcore gamer. Any serious, day one AAA gamer or needs to play games that use anti-cheat will not be happy with Linux for Windows gaming ever.
When I still used Windows it was mostly because of games and I had a second PC for that. An Xbox is another option.
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