Moment For Technology

C + + | introductory tutorial (a) c + + first

Posted on Feb. 1, 2023, 11:50 p.m. by Katie Grant
Category: c++ Tag: c++

1 c + + first

1.1 The first C++ program

1.2 annotations

Single-line comment: //

Multi-line comment: /**/

1.3 variable

Variables exist for the purpose of managing memory space

Each block of memory has a 16-bit address code

But if we use the name of the variable, we can call the data directly without using the address code.

Variable creation method:

Data type variable name = the initial value of the variable;

1.4 constant

Used to record data that cannot be modified.

C++ defines constants in two ways:

1, #define macro constants

#define constant name constant value

Usually defined at the top of a file to represent a constant.

2, const modifies variables

Const datatype variable name = constant value

If a const is added before the definition of a variable, the data cannot be modified.

1.5 the keyword

When defining constants or variables, do not use the name of a keyword. It will cause ambiguity.

1.6 Identifier naming rules

  1. Can't be a keyword
  2. It consists of letters, numbers and underscores
  3. The number must not be the first character
  4. Identifiers are case sensitive

When giving names to variables, try to know what they mean.

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.