Please help me to solve my homework

Please don't give me lecture on "Do your home work yourself "

I saw content on net but still I am unable to come to precise and to the point comments in favor of one.

The question is:

have to submit it today and it has marks also. So please do a favor. :)

If you ask people to do your homework for you, you will receive little to no help. The proper way to ask such a question is to post what you know and the answer you have come up with till now, and then ask specific questions regarding what you're having difficulty with or where you are stuck at.

1. So, what do you understand by the terms coupling, cohesion, aggregation and inheritance?

2. How do coupling and cohesion relate to aggregation or inheritance?

And don't just copy/paste from Wikipedia. What do YOU understand in your own words. You can only give an opinion in favor or against those two statements if you can answer the above two questions first.

close the thread. enough bashing.

Theres only one post. And I didn't even bash you. Man up.

The interdependency between methods and object classes is known as coupling.

The binding of the elements within one method and one object class, is known as cohesion.

[quote=", post:, topic:"]

Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a university owns various departments (e.g., chemistry), and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors. In addition, a Professor could work in more than one department, but a department could not be part of more than one university.

[/quote][quote=", post:, topic:"]

Ability of a new class to be created, from an existing class by extending it, is called inheritance

Let's use the following application as an example. Both Graduate class and Undergraduate class have similar bahavior such as managing a name, an address, a major, and a GPA. Rather than put this bahavior in both of these classes, the bahavior is placed in a new class called Student. Both Graduate and Undergraduate become subclass of the Student class, and both inherit the Student behavior.

Both Graduate and Undergraduate classes can then add additional behavior that is unique to them. For example, Graduate can be either Master's program or phD program. On the other hand, Undergraduate class might want to keep track of either the student is Freshman, Sophmore, Junior or Senior.


second again becomes tricky for me but lets try:

Aggregation is a weaker form of relationship compared and it represents a "has-a" relationship and it cannot exist on its own.

Coupling means how the entities will continue to have their independent existence.

Cohesion means a measure in terms of how a classes behaviors and attributes are related.

try posting it on

I think the way you described aggregation is incorrect. Aggregation refers to a 'collection' of related but independent objects. In the Wikipedia example you posted, professors are independent objects and if the university closes, they will still continue to exist. So it has relatively weak coupling.

Inheritance would have a stronger coupling since data members are usually part of the object and they get deleted when the object is deleted.

So you gave a hint that I should vote for inheritence and write its advantages over aggregation?

^ I just told you what I think. Its your job to figure out what to write on! :)

^very strict. ok thx. Iwill manage. :)

^ Its not a right or wrong question. You can argue both sides. So it depends on YOUR opinion!

it all depends on the system's requirements whether to use aggregation or inheritance

I have sent my comments. Now may I continue this thread for my personal homework dicussion? :D

^ Yeah sure, This will help other VU'iens too. Next time we get comment from instructor that this answer is copied from wiredPak :)

See the first post in which I sent a picture and not text. So how instructor gonna caught me? :D

^ Oye hoe :) Wah yaaar !!! Keep going... Wese bhi im least interested doing any more VU assignments myself. I find them crazy.

If we declare a function as friend of a template class will it be a friend for a particular data type or for all data types of that class?

^ 'Friendship' has nothing to do with the datatype. The function will be a friend of the class. If the friend needs to know the data type of the class instance, you can templatize the friend function as well.

What is the difference between Virtual and Multiple Inheritance?

I know that multi-inheritence should be used when a new class needs functions and features from more than one base class.

And virtual-inheritance is used when most derived classes must have only one instance of the shared base class.

You use virtual inheritance when your inheritance chain forms a diamond:


/ \

Derived1 Derived2

\ /


In the case above, when you create an instance of Derived3, you will end up with two Base objects. To solve that problem, Derived 1 and 2 will use virtual inheritance:

class Derived1: virtual public Base {};

class Derived2: virtual public Base {};

class Derived3: public Derived1, Derived2 {};

Try it out without using virtual inheritance and you'll see the problem. A call to a function in Base via a Derived3 instance will give you a compiler error (ambiguous function call).