I'm trying to create something like this:
// The code doesn't work, it should just be a pseudo to help understand what i'm trying to create
template <typename Variable>
class Address
{
unsigned int A_Address;
Variable A_Type;
void Set(A_Type value)
{
*((A_Type*)A_Address) = value;
}
A_Type Get()
{
return *((A_Type*)A_Address);
}
};
Address address_1 = new Address<float/*type*/>(0x00000000/*address in memory*/);
address_1.Set(30.0f);
float value_1 = address_1.Get();
Address address_2 = new Address<int/*type*/>(0x00000000/*address in memory*/);
address_2.Set(10);
int value_2 = address_2.Get();
So i want to be able to define objects like Address obj_1, obj_2;
and then Initialize them later with a type and an address. Then the Get() method should return it's current value in memory and the Set() method should set that value in memory. I couldn't figure out how to not do Address<float> obj_1;
and instead using Address obj_1;
and initializing it later. Hope you understood what i'm trying to do and could let me know if it's possible and if so maybe help me out or point me in the right direction.
Thanks in advance!