Re: [Dev-C++] Programming Form/Style
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jared E. <ja...@vo...> - 2001-02-25 23:05:12
|
Your friend is steering you in the right direction. You do not need to go overboard and have everything in functions. As the programmer, it is up to you to decide if a function can better suit the situation. The overall concept to think about is code reuse. For example, think about a function that adds 2 numbers. You could declare this function as a void and just have it cout the result, or you could declare the function as an int and have it return the result and do the necessary cout in the main. - Jared At 03:10 PM 2/25/2001 -0700, you wrote: >Hi, > > I am new to this list and very new to C++ and programming in > general, and I am wondering: > > My friend, who is also learning C++, told me that it is bad > programming form to declare class variables and functions public, which I > can understand for the sake of reusability and simplicity. However, he also >told me it was bad form to let Main() do too much work and that you should >send as many tasks as you can to different functions... Is this >so? Why? I can see why for more complex functions, but what about really >simple things. For example, should I even write simple output functions >to keep any "cout" lines out of main()? > > > Thanks for any help, > Trevor Cook > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |