p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Ivor Horton's Beginning Visual C++ 2005 (http://p2p.wrox.com/forumdisplay.php?f=249)
-   -   Ex 10, Chapter 5, page 253 (http://p2p.wrox.com/showthread.php?t=43207)

Nick Y May 30th, 2006 05:15 AM

Ex 10, Chapter 5, page 253
 
Receiving a Variable Number of Arguments

Answers (10 and 172630728) are incorrect; they should be 42 and 473.

Count integers (6 and 9) are missing after start of brackets of 'cout' lines.

i.e.
 cout<< sum(6, 2,4,6,8,10,12) <<endl;
 cout<< sum(9, 11,22,33,44,55,66,77,66,99) <<endl;

(Also note, second list has 66 twice and not 88 as one might assume.)


mitmaro June 16th, 2006 01:14 AM

The reason for the answers in the book:
sum(2,4,6,8,10,12) - adds 4 and 6 to get 10 the other numbers are thrown out.
sum(11,22,33,44,55,66,77,66,99) - adds the 8 values supplied plus the next 3 values in memory.

::TIM::


All times are GMT -4. The time now is 09:29 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.