I am busy with a task and i have to create a structure and with that structure i have to create and delete an object.
Here is how i created the struct with a function inside.
struct Operation
{
char op;
double (*apply)(Operation*, double,double); // takes two doubles
}
That i perfectly understand. Now the object must be created.
Operation* Make(char op)
{
Operation* ret = new Operation;
ret -> op = op;
ret -> apply = doit;//doit is a norther function
return ret;
}
I know the “->” operatic is the same as saying:
(*ret).op = op;
And the delete object;
void BrakeObject(Operation& o)
{
delete o;
o = NULL;
}
Will the function (apply) look the same as a basic function?
Is this a array?
Operation* ret = new Operation;
What is the object is it just a function?
Seems that your vision does not match the task…
A)The structure
char op;can not be an “object”. it is a “value”, hm…but
char *op;may be ok?B) Array.
Nope. you have created a pointer to single value.
C) operator. this is wrong syntax
this will be ok
D) delete
it is wrong syntax, this will be ok