We're looking at your code, and it makes no sense - no insult intended.
First you are using malloc, which is permissible, but not without using an in-place contructor to initialize the object. Like:
void * fm = malloc(sizeof(Foo));
Foo *f = new (fm) Foo();
The above will use the memory allocated by the call to malloc. new will not allocate any more. You are not however limited to classes. You can use a placement new operator for any type you would allocate with a call to new.
A 'gotcha' for placement new is that you should not release the memory allocated by a call to the placement new operator using the delete keyword. You will have to destroy the object by calling the destructor directly, and then call free to release the memory.
In your case I would suspect that using new and delete would be a better approach. If you really need to do your own memory management - overload operator new and delete for your classes.
I assume that you actually had T& Epoch as argument to what now reads as int myFunction(T Epoch) and you will need to change that to:
int myFunction(T*& Epoch)
Epoch = new T();
My guess is that you are trying to solve what shared_ptr and friends will do for you shared_ptr
But that's just an (educated?) guess ... I've been using C++ for more than 20 years too, and I still read books - books on development, automation and process control, auditing, math, physics, law, security, etc.