Namespaces
Da cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
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.
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.
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.
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
Esta seção está incompleta |
# 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.
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.
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.
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.
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.
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.
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. |