community
directory
books
authors
images
encyclopedia

Email:
Password:
Register

Knowledgerush Search

 

Google
  Web knowledgerush


Search for images of Delegation


Message boards   Post comment

Delegation

Delegation is handing a task over to a subordinate.

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.

Referenced By

Glossary of object-oriented programming

 

Compose Your Message

Your Email Address or Pen Name (optional):
Subject:
Your Message:
 

 

 

 

 

 

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Delegation".

 

Contact UsPrivacy Statement & Terms of Use

 
Copyright © 1999-2003 Knowledgerush.com. All rights reserved.