reset password
Author Message
kknaur
Posts: 540
Posted 15:00 Jan 18, 2015 |

I just wanted to remind everyone that while Global variables and constants may seem to make your programs easier to implement,  you should avoid using them as much as possible.  For this week's assignment I will concede that having the size of an array globally is helpful, the rest of the data should be created locally in a function and then passed around to other functions as necessary.

Global items can cause naming conflicts in larger c++ projects and it is very poor practice to rely on them too much.  Don't forget you have all kinds of options for passing data to a function.  You can have call-by-value and call-by-reference for most of the data types / structures in c++ so you should be considering using these options instead. 

Also remember that you cannot return a reference to locally created data (already explained exhaustively in class) and you cannot return a static array.  You can still pass arrays to your function and manipulate them and see the changes reflected outside.  Also, remember the use of const for "read only" data passed to a function.  These are all techniques I will be looking for when I grade your assignments this week.

Last edited by kknaur at 15:04 Jan 18, 2015.