The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
luck, db
There are no new questions, but there may be new answers.
naved momin wrote:consider a class room as a class ...so all the sudents will be an object of that class because all students belong to that class ...right..or wrong
if yes , then all the fans , pc , benches should also be the object of class classroom ....because they also belong to that class ?
Jesper de Jong wrote:
naved momin wrote:consider a class room as a class ...so all the sudents will be an object of that class because all students belong to that class ...right..or wrong
if yes , then all the fans , pc , benches should also be the object of class classroom ....because they also belong to that class ?
This doesn't sound right, but I'm not sure exactly what you mean because saying something like 'X becomes an object of class Y" could be understood in different ways.
It's important to understand the difference between a class and an object first. A class is a blueprint, a plan, that defines what objects of that class will look like.
For example, you can have a class House. This class defines what a House is, by the member variables and methods that it contains. Now, you can create objects out of the House class. These objects will be concrete things made out of the class. For example, you could have my house, or your house - those are objects made from the House class. Note that the House class is not a concrete house object itself - it is just the plan that explains what a house looks like.
If you want to model a classroom with students, benches, PCs, fans etc., then you could make a class for the classroom, but you would also make classes such as Student, PC, Bench, Fan etc. Then in the Classroom class, you would have member variables of the right types to refer to the students etc. that are in a classroom.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
naved momin wrote:what i understand till now is that object is just a way so that any variable can communicate with that class...is this right ?
naved momin wrote:door should be the object because it allows variables to communicate with that class....?
John Jai wrote:No - Object is a blueprint of the class
naved momin wrote:....in a ClassRoom class ..door should be the object because it allows variables to communicate with that class....?
what i understand till now is that object is just a way so that any variable can communicate with that class...is this right ?
Hug your destiny! And hug this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|