Thanks for the example! But I didn't catch the purpose of use - convenience. Please add another piece from SendParam to see how a pointer to int, for example, wants to be used.
o_O:
beautiful, but it doesn't fit.
What exactly is beautiful? It seems to be a head-on application of templates. Or maybe I'm missing something?
can memcpy be used?
no )
You see, if you have to make some preparations before calling SendParam, it's easier to wrap int into some CInt class.
There's no native way to take a pointer. I mean, if you don't use the CInt wrapper from the beginning, you'll have a hard time handling pointers.
Well, in the pluses, you do the cooking too.
{
//do something
}
{
int x = 5;
f(&x);
}
Taking an address is a preparation. Instead it's going to be
f(GetPtr(x)) plus you have to pass the type
Suppose there is a function in a class
in which the type of parameter (type) and the parameter itself, or rather a pointer to it (void*) are passed.
The parameter can be of any type (class or simple type).
The parameter can be of any type (a class or a simple type).
template<typename T>
void SendReceiveParam(T& param);
....
{
double dval = 10;
SendReceiveParam(dval);
int ival = 10;
SendReceiveParam(ival)
...
// ref on the structure object
struct AAA { void operator=(int a) {} };
AAA struct_val;
SendReceiveParam(struct_val);
}
write an illegal one via int pointers?
I still don't understand the problem's condition. Apparently, there's no clear formulation of what we want to get, even in the example.
I have already written twice that we try to pass a pointer to int into void* parameter.
( memcpy and intermediate class options have already been suggested, no need to repeat them).
I have already written twice that we try to pass a pointer to int into void* parameter.
(memcpy, intermediate class options have already been suggested, no need to repeat them)
what is the problem, legal void:
template<typename T>
void SendReceiveParam(T& param);
nice, but it doesn't fit.
it cannot pass NULL
Shit, at least in C syntax can we have an example code that should work in MQL as well?
int a=10;
SendParam(&a);
SendParam(NULL);
int a=10;
SendParam(&a);
SendParam(NULL);
beautiful, but it doesn't fit.