#include <iostream.h>

#define DATA_SIZE	127


int RomData [DATA_SIZE]; // we will call this our ROM data


//place some known values in or "Rom Data"
void InitRomData()
{
	for (unsigned i = 0; i < DATA_SIZE; i++)
  {
   	RomData [i] = i;
  }

} // end InitRomData()


class RomAccessClass
{
	public:

  static void* operator new(size_t) {return (void*)RomData;} // return the address of the ROM data
  static void operator delete (void*) {} // we will do nothing in our delete

  // the following will read the value at the Rom
	int ReadRomValue (int index) {return ((int*)this)[index];}
};


int main ()
{
 	InitRomData(); // initialise values in Rom

 	RomAccessClass* accessor = new RomAccessClass;

  // write the values out where you can see them
  for (unsigned i = 0; i < DATA_SIZE; i++)
  	{
    	cout<<accessor->ReadRomValue(i)<<endl;
    }

  delete  accessor;
}

