0

It is not necessay to write out a name of a passed variable in case of declaration:

For example its enough to write:

void myfunc(double,doble);

and not

void myfunc(double x, doble y);

But lets see a more difficult example:

template <class class_type> friend real myfunc(class_type& obj, double (class_type::*func)(double), const double&);

It is possible to eliminate the "func" which is just a name?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ramakant62
0

When we talk about the type variable then the answer is simple, the type specified in definition
Like “int iVar;” iVar is of type int.

But when we talk about the type function pointer then the type of function mean the whole name of function,
let’s take example
typedef BOOL (__stdcall *pFooo)(char *);
now you can define the variable of this function like this
pFooo MyFunction; //the type is pFoo
i.e. the pFoo is not just name it is type. In your case actually you are not specifying function pointer variable name, while you are specifying type only
use

typedef double (class_type::*func)(double);
Using Type only, as follows:
template <class class_type> friend real myfunc(class_type& obj, func, const double&);
Using Type variable as follows:
template <class class_type> friend real myfunc(class_type& obj, func MyFun, const double&);

Hope it’ll help you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.