C++
  Home arrow C++ arrow Page 3 - C++ Programming Tips
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 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++

C++ Programming Tips
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-03-12

    Table of Contents:
  • C++ Programming Tips
  • Modifying Objects
  • Advanced Parameter Passing
  • List
  • Pointers and Dynamic Memory

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    C++ Programming Tips - Advanced Parameter Passing


    (Page 3 of 5 )

    Efficiency in Using Constant Reference Parameter

    If you pass an object by value to a function, a copy of the object is first made and then passed to the called function. For large objects, copying can add considerable overhead to the program and may also adversely affect the performance of the program. For such objects, you can obtain efficiency and retain safety by passing the object as a constant reference parameter, such as the following:

    ReturnValue functionName(const type &objectName)

    The const modifier ensures that the called function does not modify the actual object.

    Abstract Data Types

    Developing object-oriented programs is typically simpler than developing procedure oriented programs. For example, member functions generally have a smaller parameter list than non-member functions because there is no need to pass the data to member functions.

    Since well-written member functions ensure that the data members are correctly initialized and updated, other program functions do not need to validate whether they are using proper object values. The access protection provided by encapsulation also ensures that clients use the public interface and not side effects of the library implementation that may continue as the implementation is modified over time.

    Rule of minimality

    The rule of minimality states that unless a behavior is needed, it should not be part of the Abstract Data Type. A corollary of this rule is the Class Minimality Principle, which states that if a function or operator can be defined such that it is not a member of the class, then do not make it a member. This practice makes a non-member function or operator generally independent of changes to the class’s implementation.

    More C++ Articles
    More By Chrysanthus Forcha


       · This article gives a C++ programmer confidence. After reading the article, you will...
     

    C++ ARTICLES

    - Multiplying Large Numbers with Karatsuba`s A...
    - Large Numbers
    - Dijkstra`s Shunting Algorithm with STL and C...
    - Brief Introduction to the STL Containers
    - The Standard Template Library
    - Templates in C++
    - C++ Programmer Alerts
    - C++ Programming Tips
    - First Steps in (C) Programming, conclusion
    - First Steps in (C) Programming, continued
    - First Steps in (C) Programming, introduction
    - C++ Preprocessor: Always Assert Your Code Is...
    - C++ Preprocessor: The Code in the Middle
    - Programming in C
    - Temporary Variables: Runtime rvalue Detection







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway