Namespace Hilfe
-
#include <iostream> using namespace std; namespace AppVersion{ namespace Version1{ void whatsup() { cout << "Whatsup 1 Call" << endl; } void display() { cout << "Display 1 Call" << endl; } } namespace Version2{ void whatsup() { cout << "Whatsup 2 Call" << endl; } void display() { cout << "Display 2 Call" << endl; } } inline namespace Version3{ void whatsup() { cout << "Whatsup 3 Call" << endl; } void display() { cout << "Display 3 Call" << endl; } } } int main() { AppVersion::display(); cin.get(); }
Wieso erzeugt dieser Code folgende Fehlermeldungen:
Fehler 2 error C2143: Syntaxfehler: Es fehlt ';' vor 'namespace' c:\users\k\documents\visual studio 2013\projects\projekt1\projekt1\main.cpp 14 1 Projekt1
Fehler 3 error C2039: 'display': Ist kein Element von 'AppVersion' c:\users\k\documents\visual studio 2013\projects\projekt1\projekt1\main.cpp 22 1 Projekt1
Fehler 4 error C3861: "display": Bezeichner wurde nicht gefunden. c:\users\k\documents\visual studio 2013\projects\projekt1\projekt1\main.cpp 22 1 Projekt1
Warnung 1 warning C4091: 'inline ': Ignoriert auf der linken Seite von 'int', wenn keine Variable deklariert wurde c:\users\k\documents\visual studio 2013\projects\projekt1\projekt1\main.cpp 14 1 Projekt1
-
Damit sagt dir VS 2013 "inline namespace kenn ich nich!"
-
Inline Namespaces kommen erst mit Visual Studio 2015:
http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx