What I want to do is have an operator= accept a template variable.
I will have some classes which all will contain an instance of a different
class. I want an operator= in yet a 3rd class to accept these classes and
use the instance. This is confusing as heck, so here's kinda what I want to
do:
class COffsetMap
{
public:
int Value;
};
class TestClass
{
TestClass& operator=( /* Here is where I want to accept a template */
SomeVar )
{
SomeVar.FieldMap // This is what I need to access
}
};
class CCharFieldMap: public COffsetMap
{
public:
void SetMap() { Value = 10; }
};
class CCharacter
{
public:
CCharFieldMap FieldMap;
};
How would I set up the template, if I even can? The whole purpose in this
is to do this in code:
TestClass Instance;
CCharacter Character;
Character.FieldMap.SetMap();
Instance = Character;
My SetMap actually sets a lot of values, which are actually offsets into the
CCharacter class (variable locations). Saying Instance = Character I would
like to load a vector in TestClass with the variables in Character which I
can get to knowing the base address of Character and the offsets (Value = 10
is just a bogus example right now).
Is this possible? To have an operator=() accept a template parameter? And
if so, how woudl I set up the template?