In object-oriented programming it is a very simple yet very powerful concept: handing a task over to another part of the program. In OO it is used to describe the situation wherein an object passes a task to another object.
In C++ say there is a class A defined as...
class A { public: foo() { cout<<"Object A doing the job"; } };
Now if there is another class B defined as...
class B { public: A a; foo() { a.foo(); } };
... any object of class B will delegate the execution of its function foo to an object of class A.
It is possible to extend this idea by making A a virtual base class and foo a pure virtual function. In that case one can further extend object A via sub classes. The result would be that during run time depending upon the subclass of the actual object stored in the variable "a" declared in class B, an appropriate foo would be called.
Search Encyclopedia
|
Featured Article
|