我的問題可能很愚蠢,但我無法通過名稱空間共享一個值。通過名稱空間共享值
namespace AceEngine
{
namespace Graphics
{
namespace Interface
{
void drawDebugScreen()
{
// I want to access AceEngine::System::Version from here.
}
}
}
namespace System
{
string Version("DEBUG");
}
}
如何訪問此字符串?
編輯:
ae.cpp
#include "stdafx.h"
#include "sha256.h"
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::getline;
using std::string;
namespace AceEngine
{
namespace Graphics
{
namespace Interface
{
void drawDebugScreen()
{
cout << "Version: " << AceEngine::System::Version << endl;
}
class Window{};
}
}
namespace System
{
class User{};
void pause(){cin.get();}
extern string Version("DEBUG");
}
}
ae.h
#pragma once
#include "stdafx.h"
#include <string>
using std::string;
namespace AceEngine
{
namespace Graphics
{
namespace Interface
{
void drawDebugScreen();
class Window{};
}
}
namespace System
{
class User{};
void pause();
extern string Version;
}
}
我刪除的無用部分(我留下了一些類來說明有東西在命名空間和它的不是無用的)
什麼是錯誤信息? – immibis 2015-03-31 07:46:40