Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Ivor Horton's Beginning Visual C++ 2010
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2010
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2010 by Ivor Horton; ISBN: 9780470500880
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2010 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2011, 12:59 PM
Registered User
 
Join Date: Feb 2011
Location: Russia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 2(Ex2_05.cpp) const double - why?

If i'm use in Ex2_05.cpp
Code:
#define rollLength 12.0*33.0
isnt this is equal to
Code:
const double rollLength =12.0*33.0;
from book?
Will there be differences in the compiled program?
If not same, then which of this better to use for better perfomance of program?Or its no point?
Thank you in advance.
P.S. Sorry for my bad language.
  #2 (permalink)  
Old March 28th, 2012, 11:19 AM
Registered User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Location: Germany
Posts: 12
Thanks: 0
Thanked 3 Times in 3 Posts
Default

There are a few reasons why I would recommend using the "const double" variant in favour of defining a macro.

1. I suspect performance is better as the data type has been explicitly defined.
2. It is more readable and clearer what the type and purpose of the variable is.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Const crmpicco VB How-To 2 May 18th, 2005 09:51 AM
how to make a const do something usefull allee_man VB How-To 2 January 4th, 2005 08:56 AM
passing a const reference in C#.NET texasraven C# 2 December 21st, 2004 06:48 PM
what's the diference between readonly and const?? gbianchi VB.NET 2002/2003 Basics 2 November 11th, 2004 02:53 PM
Const Question Greg Griffiths Classic ASP Basics 1 June 30th, 2003 01:10 PM



All times are GMT -4. The time now is 06:12 AM.


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