Namespaces
Aus 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 bieten ein Verfahren zur Verhinderung Namenskonflikte in großen Projekten .
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.
Symbole erklärt, innerhalb eines Namespace-Block in einem benannten Bereich, die sie daran hindern, für die gleichnamige Symbole in andere Bereiche verwechselt platziert werden .
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.
Mehrere Deklarationen von Namespaces mit dem gleichen Namen sind erlaubt, was in einem Namespace einschließlich aller Symbole aller solcher Erklärungen .
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.
Inhaltsverzeichnis |
[Bearbeiten]Syntax
namespace ns_name { declarations } | (1) | ||||||||
inline namespace ns_name { declarations } | (2) | (seit C++11) | |||||||
ns_name:: name | (3) | ||||||||
using namespace ns_name; | (4) | ||||||||
using ns_name:: name; | (5) | ||||||||
[Bearbeiten]Erklärung
This section is incomplete |
# Erklärung des Namensraums name .
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.
# Erklärung des Namensraums name. Definitionen erscheint sowohl innerhalb name und seine umgebenden Namensraum
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.
# Standard Methode für den Zugriff Namespace content .
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.
# Machen alle Symbole eines Namespace zugänglich im Rahmen der using-Direktive .
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.
# Making ein spezifischer Symbole eines Namespace zugänglich im Rahmen der using-Direktive .
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.
[Bearbeiten]Beispiel
Dieses Beispiel zeigt, wie ein Namespace verwenden, um eine Klasse, die bereits in der
std
Namespace benannt wurde erstellt . 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. {usingnamespace std; vector<int> v3;// Same as std::vector v1 = v3;// OK} {using vec::vector; vector<int> v4;// Same as vec::vector v2 = v4;// OK} return0;}
[Bearbeiten]Siehe auch
Namespacealias | erstellt einen Alias eines vorhandenen Namespace 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. |