Home arrow C++ arrow 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
(Page 1 of 6 )

Performance is wasted when you know the value of everything but the price of nothing.


It is not too difficult to learn a programming language like C++ when you are already familiar with another object oriented programming language such as Java or C#. Just don’t mistake the knowledge of syntax for the knowledge of semantics, because once you’ve learned the C++ syntax your programming journey is only about to begin. After you have dealt with the books and courses that help you to teach yourself C++, you will discover a need for other books that help you to become effective and exceptional at it.

One of the reasons that the C++ programming language is so powerful is because it is a very flexible language. It extends C with numerous higher level programming concepts, but remains lean and mean enough for your application to maintain good performance.

Where other languages try to make life easier for a programmer by offering features like garbage collection (which seems to be part of every new programming language these days), C++ gives you full control over memory management and basically everything else. All these "safety" features offered by other languages suffer from one thing: performance.  The reason for this is that you will need fine-grained control over the final machine code that is going to run on your target platform if you want to be able to maximize performance. This is the same gun that allows you to shoot yourself in the foot… the same gun that can make C++ so powerful.

Understanding the compiler is an important step in our semantic journey. Luckily we do not have to learn the behavior of all C++ compilers, since the C++ Standard binds them all in their functionality and behavior. In this article we are going to examine temporary objects: how and why the compiler creates them, why they can be useful, when they should be avoided and how we can help the compiler to optimize our code to make them go away.

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-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials