How to Write Standard Code in C++
There are infinitely many ways to program computers. Ultimately, it is the choice of the programmer how to accomplish what they need. There are, however, many "best practices" for styles and function usage for better compilation and safer programs. Some care should be taken to ensure that future programmers (including yourself) on your project can read and understand your code.
1. Download a C++ IDE (integrated development environment) such as Eclipse, Netbeans, and CodeBlocks, or you can use a plain text editor such as Notepad++ or VIM. You can also run programs from the command line, in that case any text-editor will suffice. It might be handy to choose an editor which supports syntax highlighting and line-numbers. Most programmers find that unix-like systems (linux, OS X, BSD) are the best environments for development.
 
2. Create a main program file. The main file must include a function called main(). This is where execution of the program begins. From here, you should be calling functions, instantiating classes, etc. Other files of your application as well as libraries can be included into this file.
3. Begin writing your program. Insert your code or the program that you need to build (see below for a few examples). Learn the syntax, symmantics, Object-Oriented Programming paradigms, data structions, algorithm designs such as linked lists, priority queues, etc. C++ is not an easy language to program in, but doing so teaches you the fundamentals that extend to all programing languages.
 
4. Insert comments in your code. Explain what your functions do and what variables are for. Choose clear names for variables and functions. Capitalize the names of global variables. In general: make sure that anyone reading your code can understand it.
5.  Use proper indenting in your code. Again, see the examples below.
6. Compile your code with
g++ main.cpp
Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here
1. Download a C++ IDE (integrated development environment) such as Eclipse, Netbeans, and CodeBlocks, or you can use a plain text editor such as Notepad++ or VIM. You can also run programs from the command line, in that case any text-editor will suffice. It might be handy to choose an editor which supports syntax highlighting and line-numbers. Most programmers find that unix-like systems (linux, OS X, BSD) are the best environments for development.
2. Create a main program file. The main file must include a function called main(). This is where execution of the program begins. From here, you should be calling functions, instantiating classes, etc. Other files of your application as well as libraries can be included into this file.
4. Insert comments in your code. Explain what your functions do and what variables are for. Choose clear names for variables and functions. Capitalize the names of global variables. In general: make sure that anyone reading your code can understand it.
6. Compile your code with
g++ main.cpp
Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here Click here
7. Run your program by typing:
      
 thank you keep visiting
thank you keep visiting 
original post : How to Write Standard Code in C++
./a.out
Examples
original post : How to Write Standard Code in C++
 
0 comments: