Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming 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
  #1 (permalink)  
Old November 19th, 2004, 12:48 PM
Authorized User
 
Join Date: Oct 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ealkurabi
Default i love C++

hmm i wonder its a newbie question but to define a variable like for example.

           #define "jfdklsajfds" USHORT
can i like make a USHORT2 or something?
like i can abbreviate howwver i want?
just a simple quesiton srry to bother just itching at my brain.

thank you

Reply With Quote
  #2 (permalink)  
Old November 19th, 2004, 05:20 PM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The general form is

#define symbolic_constant value

Where symbolic_constant is any valid C or C++ identifier (alphanumeric, first char is alpha, underscore counts as alpha, etc.)

The preprocessor will substitute the value for the symbolic_constant before handing the program to the compiler.

#define jfdklsajfds USHORT

only makes sense if USHORT is known to the compiler by the time jfdklsajfds is used in the program. Then, anywhere you use jfdklsajfds, it is af you had used USHORT
Code:
jfdklsajfds x;
printf("sizeof(x) = %d\n", sizeof(x));
Regards,

Dave
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
New To Programming would love help! davejmorley Xcode 0 July 2nd, 2007 02:15 AM





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