Welcome to weblogs.com.pk Sign in | Join | Help

OOP: Links/Relationships

I received a post on the mailing list, realizing some students/people are not able to relate the concepts of Object Oriented Programming’s links and relationships. May be this is because, generally in the class, real world examples are not presented. I am pasting the reply below, hoping it will help!

Association

Generally implemented using pointer or reference data type. eg:

UserController::AddUser(User user);

UserController is associated with User class. user is either pointer
or a reference type.

Aggregation

The aggregator class is responsible of the aggregated class life cycle. eg:

class Role { /*..*/ }
class User {
Role someRole;
User() { this.someRole=new Role();}
//...
}

Role is aggregated into User class.

Generalization/Specialization

Useful in abstraction, inheritance and polymorphism concepts. I am
unable to find words to explain it in few lines. I assume people
understand these kind of links very well. Also want to share,
Interfaces (the pure virtual base classes) also fall into this
category.
 

 

In case anyone is still confused, feel free to drop the comments to this post!

Published Monday, July 12, 2004 8:32 PM by khurram

Comments

No Comments

New Comments to this post are disabled