Aggregation and Composition

Aggregation and composition are implemented in the same way in VB. This is because unlike some languages such as C++, you cannot physically contain one VB object within another. However VB does allow you to achieve a similar effect by ensuring your composed objects are created at the same time. We achieve this by adding the 'new' keyword to the Private variable that holds the sub-object:

'Class Car

'My engine - this will be created when I get created Dim m_theEngine As New Engine

'code for class..

Was this article helpful?

0 0
365 Days Of Motivation

365 Days Of Motivation

Stop Wasting Time And Learn How To Stay Motivated. Finally! Discover How To Stop Your Mind From Wandering, And Upgrade Your Motivation. You Can Hack Your Motivation Levels, Allowing You To Take Your Life To The Next Level.

Get My Free Ebook


Post a comment