In several introductory texts on Object-oriented programming, I\'ve come across the above statement.
From wikipedia, \"In OOP, each object is capable of receivi
passing object as parameter to a method of an object that belong to a different class type. this way you pass attribute of an object to another object of a different class just call an methods of a object of an other class. so you can create an object of this class to get information of other object of different class. Note: this no override methods ok because they can be the same name but belong to a different class type. override methods is went you heritage a methods in a sub class and you change the behavior of the same methods that you get for heritance of a super class. the method to call is depending of arguments that you put in the method or the data type. the system call the right method and they can be located in a object of a superclass or in a object of a subclass.
a lot of people ask the same question. when they are working with OOP. I recommend read those old books. to understand what is OOP and not learn to programming object oriented in a programming language as CPP, JAVA and PHP. introduction to OOP (Timothy Buud) Object-Oriented Programming: An Evolutionary Approach (Brad J Cox . Andrew J Novobilski) and not forget to read Bjarne stroustrup CPP new books.
#include
#include
using namespace std;
class Car{
string brand;
public:
void setBrand(string newBrand){this->brand=newBrand;}
void Driver(){cout<<" IS DRIVING THIS CAR BRAND "<name=newName;}
//HERE WE CALL METHOD OF CAR CLASS AND REDEFINE METHODS NO OVERRIDE OK
void Driver(Car objectOfClassCar){cout<name<name<<"
"<
- 热议问题