All pastes #2096079 Raw Edit

Untitled

public cpp v1 · immutable
#2096079 ·published 2011-12-23 22:09 UTC
rendered paste body
// ------------------------------// Main.cpp#include <iostream>#include "Test.h"#include "First.h"#include "Second.h"#include "Third.h"using namespace std;int wmain(int argc, wchar_t ** argv){    Test test;    First first;    wcout << test.get_HiddenGlobal() << endl;    Second second;    wcout << test.get_HiddenGlobal() << endl;    Third third;    wcout << test.get_HiddenGlobal() << endl;    wcout << third.get_HiddenGlobal() << endl;    return 0;}// ------------------------------// Test.h#pragma oncenamespace{    int hiddenGlobal;}class Test{public:    int get_HiddenGlobal() const { return hiddenGlobal; }    void set_HiddenGlobal(int value) const { hiddenGlobal = value; }};// ------------------------------// First.h#pragma once#include "Test.h"class First{public:    First()    {        Test test;        test.set_HiddenGlobal(1);    }};// ------------------------------// Second.h#pragma once#include "Test.h"class Second{public:    Second()    {        Test test;        test.set_HiddenGlobal(2);    }};// ------------------------------// Third.h#pragma once#include "Test.h"class Third{public:    Third();    int get_HiddenGlobal() const;private:    Test test_;};// ------------------------------// Third.cpp#include "Third.h"#include "Test.h"Third::Third() : test_(){    test_.set_HiddenGlobal(3);}int Third::get_HiddenGlobal() const{    return test_.get_HiddenGlobal();}