Starting with C++
Tags: cpp, beginners, tutorial, programming
Published: 2022-12-06 11:11:46

Whenever you start a program it has a starting point on C++ the staring point is **int main().** 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5dqhdota3r4ojupqvud.png)

return 0; is an exit point of C++, it means end of the program. iostream is a header file. #include means it's a pre-processing directive. std means standard C++ namespace 



## Printing Hello World using C++


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cknwv8kzgkld0h257zt0.png)
Every statement in C++ ends with semi colon (;). cout means you output something on computer. The code behind cout is written on iostream.It is associated with the standard C output stream stdout. The data needed to be displayed on the screen is inserted 
in the standard output stream (cout) using the insertion operator(<<)

**Preprocessor directive**
The preprocessor are directives, which give instructions to the compiler to preprocess some code before actual compilation starts. The directive begins with "#". The actual code is compiled by compiler only. 

**#include directive**
Directive tells the compiler to include the header file in the source code. It's going to preprocess the code written inside<>.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2s58y3l63ltsd4rtgtl3.png)

**#define directive**
directive tells the compiler to create a symbolic constants. The symbolic constant is called macro.

All subsequent occurrences of macro in that source code will be replaced by replacement text before the program is compiled.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6qk9vtm69yivn1ols4s.png)

**Identifiers**
Both identifiers and variables are the names allotted by users to particular entity in a program. The identifier is only used to identify an entity uniquely in a program at the time of execution where variable is a name given to a memory location, that is used to hold a value. Identify is just the name whereas concept of variable means the name and bucket as well. Identify is used to give name to the bucket.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8wbo904d2uztqy863hp.png)

**Keywords**
Keywords are the word that have special meaning for the compiler. These keywords cannot be used as identifiers. C++ has about 95 reserved words.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8abmyjytzqtmuwafnjhs.png)

**Main function**
 Main is not a keyword of C/C++. Main is not predefined but it is predeclared. In C++, your code is linked against small runtime library that constitutes that constitutes the true starting point of your program. It's this small library called function main--it is hardcoded to do so. Your code runs because you supply the code inside main, also called function definition.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghetdj7voqwqgb8n47jj.png)

**Namespace**
Naming conflicts can arise if you use multiple 3rd party libraries in same program. Namespaces are used to resolve naming conflicts. std is namespace for standard C++ namespace. Writing std::cout will tell the compiler to use "cout" from standard namespace.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5f1j3vlyt4wu8nsb9no.png)

**Comments**
Comment is a text to annotate code for future references. Comment is ignored by compiler but is useful for programmers. You can use comments in testing to make certain lines of code inactive. We can write single/ multi line comment in C++ Program.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k09zbo17z9bwesg33gg3.png)