I'm feeling pretty bored while working on basic C++ classes and I'm looking to spice things up with some more advanced concepts. I've got some prior experience from an intro class I took a while back, but I need some fresh ideas to get back into it. I've already been watching YouTube videos and reading up on C++. Can you suggest ways to improve this? I've created a basic BankAccount class with some functions, but I'm ready to dive deeper!
4 Answers
If you're looking to extend your skills, consider creating a complete program around this concept. How about designing an ATM simulation? It could be as simple or complex as you want. It could really help you practice concepts like object-oriented programming by including user classes, user accounts, and more.
Consider combining your deposit and withdrawal methods into a single "transfer" method. This way, you won't need to decide which method to call for each transaction, making your code a bit cleaner and easier to manage.
A tip for your constructor is to use a member initialization list instead of assigning values within the constructor body. This approach is often more efficient and directly initializes your class members. Here's how you could do it:
BankAccount::BankAccount(int a, bool i, double b) :
accountNumber(a),
isActive(i),
balance(b) {}
One idea is to implement a check in your withdrawal method to see if the balance is zero before allowing a withdrawal! It sounds simple, but it can save a lot of trouble later on. Just imagine how many issues that could prevent!
Haha, you might have just saved my bank account! Thanks for that, lol!

Thanks for the suggestion!