0

what is the main fuction of the use of classes in real project?

2nd Jul 2016, 6:10 AM
christie
2 odpowiedzi
0
instead of just creating functions you could add them in a class and you wouldn't need to rewrite them. Adding objects may help you with behaviour of some things and some other stuff. Inheriting would allow you not to rewrite code but allow you to add code and override the base class' code and have a different one for each class without needing to rewrite functions. Sorry for bad english. It's not my first language
2nd Jul 2016, 6:33 AM
Armandas Bolevičius
Armandas Bolevičius - avatar
0
Armandas is correct. To elaborate here is a more specific example. Say we are creating a program that does our taxes. Therefore, we would have varibles based on income and whatever. Now you can use this class but initiate it for every person that you are going through the tax program. Also tax law changes every year. So your base class could be FedTax, in it are varibles and functions to use with FedTax. Now to differntiate different years could be FedTax2016 which inherets all the code from FedTax but adds in the differences for 2016... actually calling it in the program would then create an instance of it for each user and keeps wach user's data separate from each other and also means the code only needed written once.
3rd Jul 2016, 8:48 PM
Nathan D. Baker
Nathan D. Baker - avatar