what is the difference between a class and a function in a programming language??
A class is a template of variables and methods (functions) from which objects (instances) can be instantiated. A function is piece of code that does something. Many programming books compare objects to nouns and functions to verbs.
A class is a template for an object and describes what methods and properties an object of this type will have, for example is a person (object). For each person in your application, you can make a separate instance of this class that represents the person’s information. A function is a scope code that handle a bunch of codes and can returning a value (other called procedure which cann't return any values). A class is like you create a motorcycle (object) and a function like you create its reins system which manage how to operate its direction.
A class is a programmer defined data type that encapsulates data and abilities For instance, a software model of a car, a car "class", might contain data about the type of car and abilities such as accelerate or decelerate a function is a self-contained program that performs a specific well-defined purpose:including exclusively, main function and UDFs(user defined functions)
Join our real-time social learning platform and learn together with your friends!