C & C++ Programming - External Variables
/////////////////////////////////////////////////////////////////////////
// UsingExternClass.h
class CExtern
{
public:
CExtern();
CExtern(int X, int Y);
~CExtern();
int m_nCount;
};
#include "stdafx.h"
#include "UsingExternClassObj.h"
//CExtern *g_objExtern = new CExtern();
//CExtern g_objExtern;
CExtern g_objExtern(11, 22);
CExtern::CExtern()
{
m_nCount = 1000;
}
CExtern::CExtern(int X, int Y)
{
m_nCount = X * Y;
}
CExtern::~CExtern()
{
}
#include "stdafx.h"
#include "UsingExternClassObj.h"
extern CExtern g_objExtern;
int x;
void TestExtern()
{
cout << "Print the value of Count : " << g_objExtern.m_nCount << endl;
}