Espaços nominais
Variantes
Acções

Namespaces

Da cppreference.com
< cpp‎ | language

 
 
Linguagem C++
Tópicos gerais
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Controle de fluxo
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Declarações execução condicional
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Instruções de iteração
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ir declarações
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaração da função
lambda declaração da função
modelo de função
linha especificador
especificações de exceção (obsoleta)
noexcept especificador (C++11)
Exceções
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaração de namespace
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
Especificadores
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv especificadores
armazenamento duração especificadores
constexpr especificador (C++11)
auto especificador (C++11)
alignas especificador (C++11)
Inicialização
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literais
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressões
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
representações alternativas
Utilitários
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
tipo de alias declaração (C++11)
atributos (C++11)
Conversões
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversões implícitas
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Elenco C-estilo e funcional
Alocação de memória
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.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classe propriedades específicas de função
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funções membro especiais
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modelos
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
modelo de classe
modelo de função
especialização de modelo
pacotes de parâmetros (C++11)
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Assembly embutido
 
Namespaces fornecem um método para a prevenção de conflitos de nomes em grandes projetos.
Original:
Namespaces provide a method for preventing name conflicts in large projects.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Símbolos declarados dentro de um bloco namespace são colocados em um escopo nomeado que os impede de serem confundidos com símbolos com nomes idênticos em outros escopos.
Original:
Symbols declared inside a namespace block are placed in a named scope that prevents them from being mistaken for identically-named symbols in other scopes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Várias declarações de namespaces com o mesmo nome são permitidos, resultando em um espaço de nomes, incluindo todos os símbolos de todas essas declarações.
Original:
Multiple declarations of namespaces with the same name are allowed, resulting in a namespace including all symbols from all such declarations.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Sintaxe

namespace ns_name { declarations } (1)
inline namespace ns_name { declarations } (2) (desde C++11)
ns_name::name (3)
using namespace ns_name; (4)
using ns_name::name; (5)

[editar] Explicação

# Declaração da name namespace.
Original:
# Declaration of the namespace name.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
# Declaração da name namespace. Definições aparecerá tanto name dentro e seu namespace de fechamento
Original:
# Declaration of the namespace name. Definitions will appear both inside name and its enclosing namespace
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
# Maneira padrão de acesso ao conteúdo namespace.
Original:
# Standard way of accessing namespace content.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
# Fazer todos os símbolos de um espaço acessível no âmbito da directiva usando.
Original:
# Making all symbols of a namespace accessible in the scope of the using directive.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
# Fazer um símbolos específicos de um espaço acessível no âmbito da directiva usando.
Original:
# Making a specific symbols of a namespace accessible in the scope of the using directive.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

Este exemplo mostra como usar um espaço para criar uma classe que já foi nomeado no namespace std .
Original:
This example shows how to use a namespace to create a class that already has been named in the std namespace.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <vector>
 
namespace vec {
 
    template< typename T >
    class vector {
        // ...
    };
 
} // of vec
 
int main()
{
    std::vector<int> v1; // Standard vector.
    vec::vector<int> v2; // User defined vector.
 
    v1 = v2; // Error: v1 and v2 are different object's type.
 
    {
        using namespace std;
        vector<int> v3; // Same as std::vector
        v1 = v3; // OK
    }
 
    {
        using vec::vector;
        vector<int> v4; // Same as vec::vector
        v2 = v4; // OK
    }
 
    return 0;
}


[editar] Veja também

alias de namespace
cria um alias de um namespace existente
Original:
creates an alias of an existing namespace
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]