Welcome! Log In Create A New Profile

Advanced

Example exam paper

Posted by BlaXpydo 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Example exam paper
October 14, 2010 10:40AM
On question 4.2 (tut letter 103), how does one decide when to use direct data members or pointer? I have an idea, but not to sure.

Hope someone can help

_______________________________________
Don't be different...be the one making a difference
avatar Re: Example exam paper
October 15, 2010 07:47PM
Ask yourself how the data members must be created and destroyed. That should help you.
Re: Example exam paper
October 16, 2010 02:05PM
Well, I have to consider two factors: Dynamic memory allocation and Polymorphisim

_______________________________________
Don't be different...be the one making a difference
avatar Re: Example exam paper
October 17, 2010 10:51AM
Polymorphism is irrelevant.

You should be considering object ownership. By that, I mean which object is responsible for destroying the child objects. When it comes to aggregation, the ownership does not lie with the parent object, thus the parent object must not attempt to destroy the child objects. In this case, you would only have pointers to the child objects.

If you have a composition pattern, then ownership rests with the parent object. The parent can either create the child objects itself or acquire child objects during it's lifetime. If the children are to be acquired later, then a pointer would be necessary. In composition, the parent is responsible for destroying all the children.

In composition, if the child objects are not publicly accessible, you can choose when to have them statically or dynamically created. The choice depends on how many children there are and whether the number of children will change during the lifetime of the parent object.
Re: Example exam paper
October 17, 2010 06:42PM
Ok, but what if you have an hierarchy of classes, and you want the contained class to be an instance of some class in the hierarchy? Most definitely will need to use pointers.

_______________________________________
Don't be different...be the one making a difference
Re: Example exam paper
October 18, 2010 11:24AM
Hi all

Can anyone please mail me the tut103? jean.fourie@bcx.co.za.

Thanks.
Re: Example exam paper
October 18, 2010 02:13PM
email sent to you Jean.
Re: Example exam paper
October 18, 2010 10:58PM
@xtoor - ta
Re: Example exam paper
May 13, 2011 07:31AM
can someone email me me tut letter 103 2010?

44699530@mylife.unisa.ac.za
Sorry, only registered users may post in this forum.

Click here to login