C#
  Home arrow C# arrow Satview: Pointer Perfect, Part 3
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Satview: Pointer Perfect, Part 3
By: J. Nakamura
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2004-12-13

    Table of Contents:
  • Satview: Pointer Perfect, Part 3
  • Functions
  • Smart pointers
  • The meaning of ownership
  • The auto_ptr is counter-intuitive
  • The concept of source and sink

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Satview: Pointer Perfect, Part 3


    (Page 1 of 6 )

    Smart pointers allow you to manage the memory in a program yourself, without relying on garbage collectors. If you're building performance critical software, you need to know how to use pointers. In this third article in our series covering how to use pointers, J. Nakamura takes a look at what smart pointers can do, and warns about the pitfalls to avoid.

    In the previous articles we looked at methods we can use to employ pointers in C++. If pointers are that useful, then why do most modern languages make such a big deal of not using them and come with garbage collectors instead? The answer is quite simple: you need to travel quite a steep learning curve to become a responsible pointer user and it is much easier to rely on a garbage collector to look after your memory usage.

    I don’t want to start a holy language war here, but I do want to point out that when you are building performance critical software, you want to be managing the memory yourself. Even when you are not working on high performance software, you should still be aware of memory usage and the kind of tasks from which a garbage collector relieves you! There is no excuse to go on a memory abuse rampage. Computer programming is a complex task and even though the learning curve can be flattened out by using garbage collectors, it doesn’t necessarily mean that the task itself has become less complex. It all depends on what you want the machine to do for you.

    Let’s take a closer look first at why the usage of pointers can be dangerous, then I will introduce some mechanics C++ enables you to create, in order to make it safer to rely on pointers. Originally I expected that this topic would fit in one article, but there is so much to say about smart pointers that I have to spread it out over several articles instead. In this article we will mainly be looking at the STL std::auto_ptr.

    More C# Articles
    More By J. Nakamura


     

    C# ARTICLES

    - C# and XML
    - Pointers and Arrays in C#
    - C# 3.0 Extension Methods
    - Overloading Operators in C#
    - Iterators and Nullable Types
    - Patterns and Iterators in C#
    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT