Wrox Programmer Forums
|
BOOK: Beginning Visual C++ 6
This is the forum to discuss the Wrox book Beginning Visual C++ 6 by Ivor Horton; ISBN: 9780764543883
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C++ 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2005, 10:48 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default EX9_03.CPP "bug" found/explained

EX9_03.CPP (Exercising the overloaded 'greater than' operator) works as it should.

However, on page 337, Ivor incorrectly states that this code will not work:

Code:
if(aBox > 20.0)

In fact, this code does work, and does not give any errors.

To refresh your memory, the reason the code was not supposed to work was because the overloaded operator ">" can only deal with comparing two CBox objects, not one CBox ojbect versus a float value.

This is why it works:

The constructor and destructor is called and a new CBox object is created! Its volume equals the 20.0 float value! It is this object that is compared to aBox! The dimensions of this box is lv = 20.0, bv = 1.0, and hv = 1.0. Once it is done, the CBox object is destroyed.

(There exists the possibility that it works because my verson of MSVC++ is 7, and not 6. Perhaps this did not work in version 6, but I believe it will.)

___
www.matthewdoucette.com
- www.jasondoucette.com (brother/partner)
- www.sawtoothdistortion.com (tech articles)

"Discussion is an exchange of knowledge; argument is an exchange of ignorance."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ex6_02.cpp spareparts BOOK: Ivor Horton's Beginning Visual C++ 2005 1 February 19th, 2008 07:15 PM
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
Ex9_03, page 483 & '571974 Code from the book' Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 2 September 23rd, 2006 01:29 PM
Need This Explained arimakidd Beginning PHP 2 November 3rd, 2005 10:11 PM
visual cpp tanay Visual C++ 0 May 19th, 2005 08:00 AM





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