◐ Shell
clean mode source ↗

Il linguaggio C++ - cppreference.com

Da cppreference.com.

Questa pagina contiene i costrutti principali del linguaggio C++.

Concetti fondamentali

Temi generali

Preprocessore

Parole chiave

Tabella ASCII

Sequenze di escape

La storia del C++

Controllo del flusso

Istruzioni condizionali

Le istruzioni condizionali eseguono diverse parti di codice a seconda del valore dell'espressione data.

  • if esegue parti di codice condizionalmente
  • switch esegue parti di codice secondo il valore di un argomento intero

Istruzioni di iterazione

Le istruzioni di iterazione eseguono una parte di codice più volte.

Istruzioni di salto

Le istruzioni di salto spostano l'esecuzione del programma in una posizione diversa.

  • continue salta la restante parte del corpo del ciclo
  • break termina il ciclo
  • goto continua l'esecuzione in un altra posizione
  • return termina l'esecuzione della funzione

Funzioni

Lo stesso codice può essere riutilizzato in diverse posizioni del programma.

Eccezioni

Le eccezioni sono un modo più robusto per segnalare condizioni di errore rispetto ai codici ritornati dalle funzioni o alle variabili globali di errore.

Spazi dei nomi

Gli spazi dei nomi forniscono un modo per evitare conflitti sui nomi nei progetti di grandi dimensioni.

Tipi

Specifiers

Inizializzazione

Ogni volta che una variabile denominata viene dichiarata, e ogni volta che un oggetto temporaneo viene creato, il valore iniziale del nuovo oggetto viene fornito attraverso uno dei seguenti meccanismi:

Original:

Whenever a named variable is declared, and whenever a temporary object is created, the initial value of the new object is provided through one of the following mechanisms:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Letterali

Letterali sono i segni di un programma C + + che rappresentano valori costanti, incorporati nel codice sorgente.

Original:

Literals are the tokens of a C++ program that represent constant values, embedded in the source code.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Espressioni

Un'espressione è una sequenza di operatori e operandi che specifica un calcolo. Un'espressione può comportare un valore e può causare effetti indesiderati.

Original:

An expression is a sequence of operators and operands that specifies a computation. An expression can result in a value and can cause side effects.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Common operators
assegnazione incrementNJdecrement aritmetica logico confronto memberNJaccess altra

a = b a = rvalue a += b a -= b a *= b a /= b a %= b a &= b a |= b a ^= b a <<= b a >>= b

++a --a a++ a--

+a -a a + b a - b a * b a / b a % b ~a a & b a | b a ^ b a << b a >> b

!a a && b a || b

a == b a != b a < b a > b a <= b a >= b

a[b] *a &a a->b a.b a->*b a.*b

a(...) a, b (type) a ? :

Special operators
static_cast

converte un tipo a un altro
tipo compatibile

Original:

static_cast

converts one type to another compatible type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

dynamic_cast

converte classe virtuale di base per class
derivato

Original:

dynamic_cast

converts virtual base class to derived class

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

const_cast

converte il tipo di tipo compatibile con diversi cv qualifiers

Original:

const_cast

converts type to compatible type with different cv qualifiers

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

reinterpret_cast

converte tipo type
incompatibile

Original:

reinterpret_cast

converts type to incompatible type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

new

alloca memory

Original:

new

allocates memory

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

delete

dealloca memory

Original:

delete

deallocates memory

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

sizeof

interroga la dimensione di un type

Original:

sizeof

queries the size of a type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

sizeof...

interroga le dimensioni di un parametro confezione (dal C++11)

Original:

sizeof...

queries the size of a parametro confezione (dal C++11)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

typeid

interroga le informazioni sul tipo di una type

Original:

typeid

queries the type information of a type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

noexcept

controlla se un'espressione può lanciare una (dal C++11)
un'eccezione

Original:

noexcept

checks if an expression can throw an exception (dal C++11)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

alignof

query requisiti di allineamento di un (dal C++11) tipo

Original:

alignof

queries alignment requirements of a type (dal C++11)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Utilities

, Tipi

Original:

; Types

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

, Lancia

Original:

; Casts

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

, Di allocazione della memoria

Original:

; Memory allocation

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Classi

Le classi forniscono il concetto di programmazione orientata agli oggetti in C + +.

Original:

Classes provide the concept of object-oriented programming in C++.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Specifiche per una classe di funzioni proprietà

Funzioni membro speciali

Modelli

Consente di funzioni e classi di operare su tipi generici

Original:

Allows functions and classes to operate on generic types

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ottimizzazioni

Varie