Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Note, a function in a class is commonly called method. I will assume you meant regular functions/methods here, rather than the constructor and destructor, which are also functions, with a distinct purpose. ● Why define a method? to add ability for the class to "do" something. ● Is it necessary? it depends, if you need your class to be able to process something then yes, some classes are designed only as data storage, for other class to process, in this case, method is not necessary. ● Class without a function, what to call it? I'm not sure if there is a special name for such classes. Others can tell you better I'm sure. ● How many methods can we define? I can't tell you that, but I can tell you it is better to design your class slim, focus on what they are meant for, nothing irrelevant should be in the class. ● I'm not sure I understand what you mean by rates here, so I have nothing to say. Sorry I couldn't answer all your questions, but no worries, there are others here who can add more; Hth, cmiiw
27th Nov 2018, 2:15 PM
Ipang