D
David student
Guest
Hello All,
How to avoid pointers, dynamic allocation, and malloc when using the function pointer in the class in C++
mailAPI is the function pointer of the structure. And this structure has the callbacks like as shown below:
mailcallbacks.h
typedef struct
{
short (*getmails) (int * numberOfmails);
}mailAPI;
I am using the above defined function pointer (mailAPI) like as shown below:
CMyClass.h
static mailAPI* m_pAPIs;
CMyClass.cpp
mailAPI* CMyClass::m_pAPIs = nullptr;
int CMyClass::Initialize()
{
m_pAPIs = (mailAPI*)malloc(sizeof(mailAPI));
if (m_pAPIs == nullptr)
{
return -1;
}
}
I was asked to avoid pointers, dynamic allocation, and malloc.
And asked to define statically in the class.
Can someone please help me how to do this?
Thanks in Advance,
Continue reading...
How to avoid pointers, dynamic allocation, and malloc when using the function pointer in the class in C++
mailAPI is the function pointer of the structure. And this structure has the callbacks like as shown below:
mailcallbacks.h
typedef struct
{
short (*getmails) (int * numberOfmails);
}mailAPI;
I am using the above defined function pointer (mailAPI) like as shown below:
CMyClass.h
static mailAPI* m_pAPIs;
CMyClass.cpp
mailAPI* CMyClass::m_pAPIs = nullptr;
int CMyClass::Initialize()
{
m_pAPIs = (mailAPI*)malloc(sizeof(mailAPI));
if (m_pAPIs == nullptr)
{
return -1;
}
}
I was asked to avoid pointers, dynamic allocation, and malloc.
And asked to define statically in the class.
Can someone please help me how to do this?
Thanks in Advance,
Continue reading...