3 ms·
I've recently been jumping around in my naming conventions. I'm a student and haven't quite settled in one one particular convention. For the current project I'
by TravisPe 15y ago
I've recently been jumping around in my naming conventions. I'm a student and haven't quite settled in one one particular convention. For the current project I'm working on (C++) I've been using function overloading. So for example, I have a class called BankAccount. I have a private and a public method that will set the balance or return the balance (set is private, get is public) of the account, I've overloaded this so that if no parameter is passed it returns the balance, and if a parameter is passed it will set the balance accordingly. I use this in my deposit and withdrawal methods. I do the same thing for other setters/getters. I picked up this convention from seeing it used in other languages like Ruby and Javascript.
Is this a bad practice? It seems logical to me, but I'm wonder what other peoples thoughts are and if it may be confusing to someone else.