我的问题可能很愚蠢,但我无法通过名称空间共享一个值。通过名称空间共享值
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