Answer the question
In order to leave comments, you need to log in
What does it mean to model real world objects in OOP?
"OOP programs model real world objects, so the complexity is reduced and the structure is clearer." Please explain with examples
Answer the question
In order to leave comments, you need to log in
Imagine that you need to write a program that keeps a record of private houses on some street. The key unit will be the house - an object from the real world. To describe it using program code, OOP is great for this. It has such a concept as a class, it is essentially a model / structure of an object from the real world. In our example with a house, this would be something like this class:
class House {
string address;
int numOfRooms;
...
House(string address, int numOfRooms)
{
this.address = address;
this.numOfRooms = numOfRooms;
}
}
class Dog {
string name;
string breed;
Dog(string name, string breed)
{
this.name = name;
this.breed = breed;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question