Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: I need help with my homework!! Emergency!!!

Reply
Thread Tools

Re: I need help with my homework!! Emergency!!!

 
 
Mike
Guest
Posts: n/a
 
      11-23-2004

"Raymond Martineau" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 20 Nov 2004 18:24:42 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) (DaMentor) wrote:
>
> >Hey guys, I need help with this program. So far I've tried everything
> >I know and can't get this thing to work properly. If someone has any
> >suggestions please send them to me. Thanks.
> >

>
> If you are asking for help on why a program isn't working, you should
> either post an error log of the compilation process, or provide

information
> about why it is not working and it's expected result.
>
> >
> >// Purpose: Program calculates the amount of time necessary to reach a
> >certain
> >// financial goal by consistantly depositing the same amount of money
> >// into an interest-bearing account each month. The account is
> >comounded monthly.

>
> For comment blocks, you should use the "/* */" comment delimiters. The
> "//" comment delimeters are prone to wordwrapping from standard

newsreaders
> and will cause errors that were not present in the first place.
>
> >include <iostream.h>
> >include <stdlib.h>

>
> Include statements should be preceeded with a "#". Even then, one of

these
> header files is depreciated (as stated by another poster.)
>
> >float months = 0;

>
> Why not declare this as an int instead of a float? Unless you plan to
> expand your program to calculate daily interest, there's no reason to

spend
> extra cycles on calculating floating point.
>
> > total = total + (total * monthly_interest);

>
> Instead, use:
>
> total += total * monthly_interest;
>
> > months++;

>
> Use "++months" instead. While post-increment does work here (and isn't
> much of a problem in C), you should change the habit for C++ as
> post-increment is slightly less efficient when you begin to deal with
> classes.
>


I've heard that said before? Why is this??
Thanks

Mike


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      11-23-2004
Mike wrote:

> > total += total * monthly_interest;
> >
> > > months++;

> >
> > Use "++months" instead. While post-increment does work here (and isn't
> > much of a problem in C), you should change the habit for C++ as
> > post-increment is slightly less efficient when you begin to deal with
> > classes.
> >

>
> I've heard that said before? Why is this??


If you write Class:perator++(int) yourself, it must return a temporary
containing the value before incrementation.

(The 'int' part is just a keyword re-used as a flag "I'm the post-increment
version").

The compiler cannot easily optimize away this temporary object.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
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
Help Help, I am intermediate in Java...need help in follow case ElementX Java 9 10-01-2008 08:02 PM
Help Help. I really need some help with this =?Utf-8?B?Q2hyaXM=?= ASP .Net 3 01-31-2007 09:33 PM
re_---need help Network Adapters!!!! NEED HELP!!!! hedayatniac@gmail.com Computer Support 4 08-13-2006 01:03 AM
Need help! I need to add lead zeros to a textbox Teep ASP .Net 2 06-21-2004 01:04 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM



Advertisments