GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


An array system for C++ Free Stuff

Abstract

This article presents a system for C++ arrays. This system is superior to the arrays that are built into the C and C++ languages in that arrays can be resized dynamically at runtime and also they are safer to use through the use of assertions to guard against array out of bounds errors.

1. Using Arrays

See the file t-array.cc for examples of using arrays. Multi-dimensional arrays are also supported. See the source code file t-array.cc for an example of their use. Like C arrays, the indexing is opposite from normal use. Here is how to index into a two-dimensional array:

a->get_element_at(y)->get_element_at(x)

Note that deletions from multi-dimensional arrays is non-trivial. See the source code file for an example of deleting from multi-dimensional arrays. When using multi-dimensional arrays, typedefs are useful: The following line of code defines an alias for a two-dimensional array of ints.

typedef Array<Array<int> > Array_Array_Int

In the above example, care must be taken to put spaces between the closing >'s.

2. The Source Code

  • Array system classes
  • array.hh
  • Tester Module:
  • t-array.cc

    Back to Research Projects
    This page has the following hit count:
    | Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
    | Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
    | Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
    | Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
    | String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
    | Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
    | Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
    | Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
    | Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
    | S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
    | Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
    | J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
    | Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
    | More Occam's Razor | C to Java Translator | Theory of Morality II
    Last modified: Sun Sep 25 16:11:43 NZDT 2016
    Best viewed at 800x600 or above resolution.
    © Copyright 1999-2016 Davin Pearson.
    Please report any broken links to