+ 1
Anyone to describe more about objects and classes
4 Answers
+ 7
when you submit a question, name the language in the tags section so ppl find it easily to answer.
+ 6
which language?
+ 2
Making a class can be thought of as defining a data type, and an object can be thought of as a variable of that data type. Each object has its own set of variables that you put in the class, completely unique for it. Just like if you have 2 ints and change the value of one, the other one does not change. Methods are functions inside the object that can be used to interact with all of the variables in the object, including private ones. You call a method like this:
objName.methodName(param);
+ 1
@Musa Enocy Object is an instance of a class. Basically you can think of class as a data type and object as a varible.When we create an object from a class object will have access to all the data(variables) and methods(functions) of the class. EX: a BANK is class and it might have data (variables) like name, DOB, address, totalAmount etc and methods (functions) can be display amount, display account details, transfer etc. And we can think all the account holders in the BANK as objects. Every member(object) will have access to all the data and methods of the BANK(class) and their data is hidden(encapsulated) from other account holders(objects).