Namespaces
De 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. |
Espacios de nombres proporcionar un método para evitar conflictos de nombres en grandes proyectos .
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 declaradas dentro de un bloque de espacio de nombres se colocan en un ámbito con nombre que les impide ser confundido con símbolos que se denominen en otros ámbitos .
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.
Múltiples declaraciones de espacios de nombres con el mismo nombre se les permite, dando lugar a un espacio de nombres incluyendo todos los símbolos de todas esas declaraciones .
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.
Contenido |
[editar] Sintaxis
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] Explicación
This section is incomplete |
# Declaración de la name espacio de nombres .
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.
# Declaración de la name espacio de nombres. Las definiciones aparecen tanto dentro como name su espacio de nombres contiene
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.
Camino # Estándar de acceso al contenido de espacio de nombres .
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.
# Hacer que todos los símbolos de un espacio de acceso en el ámbito de aplicación de la directiva using .
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.
# Realización de una simbología específica de un espacio de nombres accesibles en el ámbito de aplicación de la directiva using .
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] Ejemplo
En este ejemplo se muestra cómo utilizar un espacio de nombres para crear una clase que ya ha sido nombrado en el espacio de nombres
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] Ver también
alias de espacios de nombres | crea un alias de un espacio de nombres 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. |