Home
1.
What are runtime errors, and how are they different from compile-time errors?

Errors that happen when you execute your application are called runtime errors. You might have experienced the infamous "Access Violation" on older versions of Windows, which is a runtime error. Compile-time errors don't reach the end-user and are an indication of syntactical problems; they keep the programmer from generating an executable.

2.
What is the difference between an interpreter and a compiler?

An interpreter is a tool that interprets what you code (or an intermediate byte code) and performs certain actions.
A compiler is one that takes your code as an input and generates an object file. In the case of C++, after compiling and linking you have an executable that can run directly by the processor without need for any further interpretation.

3.
What does the linker do?

A compiler takes a C++ code file as input and generates an object file in machine language. Often your code has dependencies on libraries and functions in other code files. Creating these links and generating an executable that integrates all dependencies directly and indirectly coded by you is the job of the linker.

4.
What are the steps in the normal development cycle?

Code. Compile to create object file. Link to create executable. Execute to test. Debug. Fix errors in code and repeat the steps. In many cases, compilation and linking is one step.

5.
When do you need to program command-line arguments?

To supply options that allow the user to alter the behavior of a program. For example, the command ls in Linux or dir in Windows enables you to see the contents within the current directory or folder. To view files in another directory, you specify the path of the same using command-line arguments, as in ls / or dir \..

6.
What is the problem in declaring Int main()?

Code in C++ is case sensitive. Int is not acceptable to the compiler as an integer type int.

7.
Why should I not use global variables frequently? Isn't it true that they're usable throughout my application and I can save some time otherwise lost to passing values around functions?

Global variables can be read and assigned globally. The latter is the problem as they can be changed globally. Assume you are working on a project with a few other programmers in a team. You have declared your integers and other variables to be global. If any programmer in your team changes the value of your integer inadvertently in his code-which even might be a different .CPP file than the one you are using-the reliability of your code is affected. So, sparing a few seconds or minutes should not be criteria, and you should not use global variables indiscriminately to ensure the stability of your code.

8.
How would you use cin to get a complete line from the input stream?

You would use cin.getline().

9.
Why should I initialize the value of a variable?

If you don't initialize, you don't know what the variable contains for a starting value. The starting value is just the contents of the location in the memory that are reserved for the variable. Initialization such as that seen here:
int myFavoriteNumber = 0;
writes the initial value of your choosing, in this case 0, to the memory location reserved for the variable myFavoriteNumber as soon as it is created. There are situations where you do conditional processing depending on the value of a variable (often checked against nonzero).
Such logic does not work reliably without initialization because an unassigned or initiated variable contains junk that is often nonzero and random.

10.
Why does C++ give me the option of using short int and int and long int? Why not just always use the integer that always allows for the highest number to be stored within?

C++ is a programming language that is used to program for a variety of applications, many running on devices with little computing capacity or memory resources. The simple old cell phone is one example where processing capacity and available memory are both limited.
In this case, the programmer can often save memory or speed or both by choosing the right kind of variable if he doesn't need high values. If you are programming on a regular desktop or a high-end smartphone, chances are that the performance gained or memory saved in choosing one integer type over another is going to be insignificant and in some cases even absent.