Introductions of Class:
Class:
- Class is used to hold data members and member function i.e. variables and functions.
- It can be easily accessed anywhere and used to reduce the reusability of the code.
- The class name is a user-defined word.
For example,
- Let’s take student,
- Student properties are all called variables and student performance or student-related calculations(i.e. student result based on total and it may be pass or fail) is called as a function.
Where,
The student is a class.
Student properties (variables) : Roll_num,name,age,ect.
Student behaviours(function) : total,average,result,fees details ect.
Note:
- If one or more variables declared within the class, called data members.
- If one or more functions declared within the class, called member function.
Syntax:
No comments:
Post a Comment