Home arrow C++ arrow Page 2 - Temporary Variables: Procrastination is the Thief of Time

Temporary Variables: Procrastination is the Thief of Time

C++ is a powerful programming language to learn, in part because it gives you full control over memory management. This is a two-edged sword, however; it lets you improve the performance of your code, but it also lets you shoot yourself in the foot. Therefore, it is important to understand the C++ compiler. This article examines how and why the compiler creates temporary objects, among other topics.

Author Info:
By: J. Nakamura
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
September 19, 2005
  1. · Temporary Variables: Procrastination is the Thief of Time
  2. · Temporary Object Terminology
  3. · More than just a call
  4. · To return or not to return an object
  5. · Visualizing the unseen object
  6. · Back to the closest Enemy

print this article

Temporary Variables: Procrastination is the Thief of Time - Temporary Object Terminology
(Page 2 of 6 )

Temporary (adj).

 Lasting, used, serving, or enjoyed for a limited time.

Maybe you have run into the terms rvalue and/or lvalue while reading about C++. These are the terms used by the C++ Standard to discriminate between named objects (lvalues) and unnamed objects (rvalues).

According to the Wikipedia:

An lvalue is an expression that designates (refers to) an object. A non-modifiable lvalue is addressable, but not assignable. A modifiable lvalue allows the designated object to be changed as well as examined. An rvalue is any expression that isnít an lvalue, it refers to a data value that is stored at some address in memory.

What this basically means is that an lvalue (named object) is created every time you declare a variable explicitly (e.g. int i=1; or MyObject obj;). We are going to take a closer look at rvalues. These are the unseen temporary objects that are needed to implement parts of the C++ language (such as operator overloading). You never get to see them because they are fully handled by the compiler.

blog comments powered by Disqus

- Intel Threading Building Blocks
- Threading Building Blocks with C++
- Video Memory Programming in Text Mode
- More Tricks to Gain Speed in Programming Con...
- Easy and Efficient Programming for Contests
- Preparing For Programming Contests
- Programming Contests: Why Bother?
- Polymorphism in C++
- Overview of Virtual Functions
- Inheritance in C++
- Extending the Basic Streams in C++
- Using Stringstreams in C++
- Custom Stream Manipulation in C++
- General Stream Manipulation in C++
- Serialize Your Class into Streams in C++

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials