class forms | Sololearn: Learn to code for FREE!


class forms

why are we define a function in a class; does it necessary? does we have a class with out a function?what do we call it if we have?

11/27/2018 9:51:11 AM

Nafiseh sadat ahouie

3 Answers

New Answer


how many function can i define in a class at most and at list? does there is any rates between the numbers of method and properties and function in a class?


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