mardi 31 mars 2015

Sharing values through namespaces

My question is probably stupid, but I can't share a value through namespaces.



namespace AceEngine
{
namespace Graphics
{
namespace Interface
{
void drawDebugScreen()
{
// I want to access AceEngine::System::Version from here.
}
}
}

namespace System
{
string Version("DEBUG");
}
}


How can I access this string?


EDIT:


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;
}
}


I removed the useless parts (I left some classes to show there are stuff in the namespaces and it's not useless)


Aucun commentaire:

Enregistrer un commentaire