C
carl.eichert
I need to change DMapEntry:Data from a char* to a class DMapData that contains the original pointer but still be able to refer to &pData[offset] in DMapEntry without changing it. Is this possible?
#include "stdafx.h"
class DMapData {
char* pData;
public:
char* operator->() { return pData; }
char operator[](size_t offset) { return pData[offset]; }
friend class DMapEntry;
};
class DMapEntry {
char* pStr;
public:
DMapData pData;
/*----->*/ void getStr(size_t offset) { pStr = &pData[offset]; }
};
int _tmain(int argc, _TCHAR* argv[])
{
DMapEntry a;
return 0;
}
Carl
Lomita, CA
#include "stdafx.h"
class DMapData {
char* pData;
public:
char* operator->() { return pData; }
char operator[](size_t offset) { return pData[offset]; }
friend class DMapEntry;
};
class DMapEntry {
char* pStr;
public:
DMapData pData;
/*----->*/ void getStr(size_t offset) { pStr = &pData[offset]; }
};
int _tmain(int argc, _TCHAR* argv[])
{
DMapEntry a;
return 0;
}
Carl
Lomita, CA