1. Helpful Programming Ideas: #2

    Think, use, and re-use patterns.

    Much of the process of programming can be described by patterns of syntax. By recognizing these patterns, you can get into habits that reduce the amount of work you do and may help remove some inadvertent errors. Here are two patterns:

    • By now, you have probably written the same lines to start off a program several times (the #include<iostream> to the int main()) and it is very likely every program will need this set of code. Why not create a main.cpp file which contains that core code so you can easily cut and paste it into a new program?
    • To prevent memory leaks, every new requires an associated delete - if possible, write the delete statement when you write the new statement.