03-22-2008
How to return void function pointer
Hello all
im trying to build function that will return void function pointer
what is mean is ( not working )
the main function
PHP Code:
void * myClass::getFunction(int type){
if(type==1)
return &myClass::Test1;
if(type==2)
return &myClass::Test2;
}
void myClass::Test1(){
printf("nada1");
}
void myClass::Test2(){
printf("nada2");
}
what im doing wrong here ?
10 More Discussions You Might Find Interesting
1. Programming
i have a function:
char *pcCityIdToCountryName(ADMIN_DB_DATA *pstHEader, unit uiCityID)
this returns a pointer to CountryName if cityId is given.
to retrieve countryname i give:
char *CountryName;
CountryName = pcCityIdToCountryName(..................);
but when i compile it is giving :... (5 Replies)
Discussion started by: jazz
5 Replies
2. Programming
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
3. Programming
Hi.
Problem: I have to parse the payload of a packet. The payload could be in Big Endian Format (network byte order) or little. That depends on a flag present in the header of the packet.
Solution: A horrible solution could be to check for that flag everytime I have to read a field in the... (11 Replies)
Discussion started by: emitrax
11 Replies
4. Programming
Hi guys.
how a functions such fdopen, ... can return pointer?
are these functions use static memory(variables)? (6 Replies)
Discussion started by: majid.merkava
6 Replies
5. HP-UX
i am trying to convert void pointer to pthread_t on hpux-itanium 64 bit which fails as below
"src/file.cpp", line 88: error #2171: invalid type conversion
pthread_t tid = reinterpret_cast<pthread_t>(m_threadId);
1 error detected in the compilation of "src/file.cpp"
... (0 Replies)
Discussion started by: skyineyes
0 Replies
6. Programming
hi guys!
Is there such a thing as double void pointer dynamic allocation?
And if so is it something like this?
int n;
void** a;
a=malloc(n*sizeof(void*)); (12 Replies)
Discussion started by: vlm
12 Replies
7. Programming
Earlier I had one structure C
typedef struct c
{
int cc;
}CS;
I used to call a library function say int GetData(CS *x) which was returning me the above structure C with data.
GetData(CS *x)
Function call used to be like:
CS CSobj;
GetData(&CSObj);
Now there are two... (12 Replies)
Discussion started by: rupeshkp728
12 Replies
8. Programming
I have a function to which I will pass a struct ID and it will return me a string.
I will pass a pointer to store the name string and that pointer will be allocated memory by the function called.
int ConvertIDToName(void *id, void *name, size_t *size)
{
int status = 0;
... (5 Replies)
Discussion started by: rupeshkp728
5 Replies
9. Shell Programming and Scripting
Not sure where the problem is. I can run the script without any issue using the following command.
. /opt/app/scripts/cdc_migration.sh
But it fails with the below error when I try it this way
/opt/app/scripts/cdc_migration.sh
/opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies
10. Shell Programming and Scripting
Hi All,
Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition.
#Body
function1()
{
if
then
echo "exist"
else
echo "not exist"
}
#if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
LEARN ABOUT NETBSD
field_term
FORMS(3) BSD Library Functions Manual FORMS(3)
NAME
field_init, field_term, form_init, form_term, set_field_init, set_field_term, set_form_init, set_form_term -- form library
LIBRARY
Curses Form Library (libform, -lform)
SYNOPSIS
#include <form.h>
void (*)(FORM *)
field_init(FORM *form);
void (*)(FORM *)
field_term(FORM *form);
void (*)(FORM *)
form_init(FORM *form);
void (*)(FORM *)
form_term(FORM *form);
int
set_field_init(FORM *form, void (*function)(FORM *));
int
set_field_term(FORM *form, void (*function)(FORM *));
int
set_form_init(FORM *form, void (*function)(FORM *));
int
set_form_term(FORM *form, void (*function)(FORM *));
DESCRIPTION
The field_init() function returns a pointer to the function that will be called just after the current field changes and just before the form
is posted, this function may be set by using the set_field_init() function. Similarly, the function field_term() will return a pointer to
the function that will be called just before the current field changes and just after the form is unposted, this function pointer may be set
by using the set_field_term() function. The form_init() function will return a pointer to the function that will be called just before the
form is posted to the screen, this function can be set by calling the set_form_init() function. The form_term() function will return a
pointer to the function that will be called just after the form is unposted from the screen, this function may be set by using the
set_form_term() function. By default, the init and term function pointers are NULL.
RETURN VALUES
Functions returning pointers will return NULL if an error is detected. The functions that return an int will return one of the following
error values:
E_OK The function was successful.
SEE ALSO
curses(3), forms(3)
NOTES
The header <form.h> automatically includes both <curses.h> and <eti.h>.
BSD
January 1, 2001 BSD