Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Solve this question

Reply
Thread Tools

Solve this question

 
 
Diego Martins
Guest
Posts: n/a
 
      01-22-2007

Gavin Deane wrote:
> osmium wrote:
> > template <class T>
> > class Gpa
> > {
> > public:
> > Gpa();
> > ~Gpa();
> > void input(); /* number of inputs are
> > unknown. Terminate with EOF*/
> > double cal_gpa();
> > private:
> > T* presult; // pointer to an array
> > int na; // current size of result array.
> > // try starting with na = 6 or so.
> > };
> > Some people would prefer vector to array, I don't have any really strong
> > feelings there.

>
> Really? The assignment calls for an array, so presumably a vector would
> not be acceptable. But having said that, I would have thought this is a
> perfect example of how vectors could make your life easier. Nothing in
> the spec says anything about how many courses a particular student
> might have taken. The examples happen to use 5, but that's not stated
> as a requirement. Using an array implies needing to keep count of how
> many entries you've made so far, and reallocating as required. Exactly
> the sort of things a vector does for you. Unless the point of this
> assignment is to learn how to do that sort of thing by hand (unlikely -
> since the point seems to be something about templates) the requirement
> to use an array looks to me like an unnecessary complication. The only
> other possibility that occurs is that, after this assignment is handed
> in, the class will be shown how much simpler it could be with a vector,
> but again, that message would probably be confused amongst the
> templates.
>
> Gavin Deane


I don't know and I don't care what is a GPA, but we have to admit it is
a good exercise to build an array<> or a matrix<> template in the
classroom.
It is very good for learning templates, constructors, destructors,
memory management, first class objects...

Diego

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Some One Solve This Two Question..i Will Be Very Thank Ful To It sohailkhan4444 General Computer Support 0 07-13-2009 03:34 PM
Please solve this question reepakmajhi.com@gmail.com C++ 6 09-29-2008 08:21 AM
Help! to solve this question argszero Java 20 09-14-2007 12:31 PM
Newbie question about how to solve the use escape characters Mark Chao XML 2 11-16-2005 10:42 PM
SVD Back Solve Method Question Oracle3001 Java 0 10-13-2003 01:48 PM



Advertisments