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++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 6th, 2006, 05:49 PM
Registered User
 
Join Date: Feb 2005
Location: , , Canada.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to random_eh
Default Help a student re: Re-using variables

In main I use a variable say "char user_input;" then I no longer have a need for that particular variable. However, I do need another variable say "char function_result;"

The way I see it I can easily do two things:
 1) make a new variable
 2) or use the old variable
but is there a way to rename the old variable with the new name?
Reply With Quote
  #2 (permalink)  
Old February 7th, 2006, 12:54 AM
Authorized User
 
Join Date: Oct 2004
Location: San Francisco, CA, .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nope. Make a new one -- it's stylistically more pleasing for a tiny (and temporary) impact on memory consumption.

----
Scott J. Kleper
Author, "Professional C++"
(Wrox, 2005)
Reply With Quote
  #3 (permalink)  
Old February 7th, 2006, 04:57 PM
Registered User
 
Join Date: Feb 2006
Location: , , Philippines.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mikhailberis
Default

There is a way, but it might be clumsy.

You can do something like this:

...
char my_first_char;
// do other things
// then use the old variable
// to use the space of the old variable
char & another_char(my_first_char);

Dean Michael C. Berris
Orange and Bronze Technologies, Inc.
Mobile +639287291459
Reply With Quote
  #4 (permalink)  
Old February 27th, 2006, 08:47 AM
Authorized User
 
Join Date: Nov 2005
Location: , , India.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Its not renaming...it's giving another name. :)

Reply With Quote
Reply


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
Student login form aaronjaf Access 1 May 8th, 2006 03:29 AM
*student* in need of help satinder Access 2 April 4th, 2005 06:32 AM
* student * in need of help satinder Classic ASP Databases 1 April 2nd, 2005 08:34 AM
Student Version stu9820 Dreamweaver (all versions) 3 September 7th, 2004 04:32 PM



All times are GMT -4. The time now is 03:58 PM.


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