Welcome! Log In Create A New Profile

Advanced

Assignment 4 Questions 4 and 5

Posted by Henry 
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
avatar Assignment 4 Questions 4 and 5
July 13, 2008 11:31AM
I don't see much difference between these 2 questions. Do any of you?
Re: Assignment 4 Questions 4 and 5
July 13, 2008 12:48PM
me neither
Re: Assignment 4 Questions 4 and 5
July 13, 2008 01:00PM
how will we answer that one then
avatar Re: Assignment 4 Questions 4 and 5
July 13, 2008 01:34PM
Copy and paste? smileys with beer
Re: Assignment 4 Questions 4 and 5
July 13, 2008 02:26PM
Re: Assignment 4 Questions 4 and 5
July 13, 2008 02:28PM
Did u have a look at Q6. Am I reading correctly that we should make a 2D vector. If so were in the book do they show how to do it?? This one is getting me.
Re: Assignment 4 Questions 4 and 5
July 13, 2008 02:34PM
...its a vector in a vector...that took me a while...confused smiley
Re: Assignment 4 Questions 4 and 5
July 15, 2008 09:10AM
the are a lot of web sites that gives info on how to use a 2D vector
avatar Re: Assignment 4 Questions 4 and 5
July 15, 2008 12:58PM
I don't know what you guys are on about. We are are just talking about plain old 2 X 2 matrices. Just follow the note following the question on the algebra of matrices if you have not done the linear algebra (MAT103) or COS101 modules yet. Or consult Wikipedia on introductory linear algebra and how to add, subtract matrices.

You don't have to know the intricacies of 2D vectors to do this question.
Re: Assignment 4 Questions 4 and 5
July 16, 2008 09:43AM
I had no problem with the matrices. Just didnt read the given code properly, overlooked the way they stated the 2D vectors.
avatar Re: Assignment 4 Questions 4 and 5
July 17, 2008 01:00PM
Oh that! Sorryyawning smiley

I thought you guys we talking about it math wise.

Yes, remember that a template can (should) take ANY object, even if that be another template class, ad infinitum.

That is the way to do multi-dimensional dynamic arrays in OO languages that support templates.
Re: Assignment 4 Questions 4 and 5
July 17, 2008 01:13PM
Re: q4and5

q5 is so much less limited. You can use bool as your return type. After all, the goal with no.5 is just to determine IF there's a certain value, not WHERE it is.Not to mention the fact that it technically doesn't require you to also submit the output, seeing as it doesn't tell you to test it using a driver programeye rolling smileytongue sticking out smiley
Re: Assignment 4 Questions 4 and 5
July 17, 2008 02:54PM
They will probably not even mark Question 5, but just for the fun I decided to implement a recursive template function - sweet. smile
Re: Assignment 4 Questions 4 and 5
July 17, 2008 08:08PM
Any idea on how to stop the entry of a char into an array? As in:

while ((next >= 0)&&(index < size))||((next != 'X'winking smiley&&(index < size))
{
values[index] = next;
index++;
cin >> next;
Re: Assignment 4 Questions 4 and 5
July 17, 2008 10:07PM
not sure what is the logic behind "((next >= 0)&&(index < size))||". the Later condition "((next != 'X'winking smiley&&(index < size))" works just fine.

(next >= 0 || next != 'X'winking smiley can never be be false cause a char will always be >=0 so the only time your loop will end is when index becomes >= size.
Re: Assignment 4 Questions 4 and 5
July 17, 2008 10:40PM
Yes I put the || part in to cater for char and the first part to cater for double and int, to make the function generic but it doesn't work.
avatar Re: Assignment 4 Questions 4 and 5
July 17, 2008 10:49PM
Why go thru all these troubles? I don't think they ask you to enter the values from the keyboard. I just used 2 arrays in my main program, one being a char array and one an int array to prove that my template function work for both types of arrays.

No need to torture yourself if not needed.
Re: Assignment 4 Questions 4 and 5
July 17, 2008 11:24PM
Oh, but did you fill the array partially before passing it to the generic function or did you populate the array via a function?
avatar Re: Assignment 4 Questions 4 and 5
July 17, 2008 11:45PM
did not even use a function...
Re: Assignment 4 Questions 4 and 5
July 18, 2008 12:52AM
OK going to simplify mine alot too then, thanks
Sorry, only registered users may post in this forum.

Click here to login