Click here to Skip to main content
14,765,654 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Richard MacCutchan3-Jun-16 0:40
mveRichard MacCutchan3-Jun-16 0:40 
GeneralRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Member 125258023-Jun-16 2:59
MemberMember 125258023-Jun-16 2:59 
GeneralRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Jochen Arndt3-Jun-16 3:38
professionalJochen Arndt3-Jun-16 3:38 
GeneralRe: what is the difference between definition numeric value 0.0, .0, 0.? Pin
Richard MacCutchan3-Jun-16 3:42
mveRichard MacCutchan3-Jun-16 3:42 
QuestionSyntax of How to Call a Member Function via a Function Pointer Pin
Bram van Kampen1-Jun-16 15:37
MemberBram van Kampen1-Jun-16 15:37 
AnswerRe: Syntax of How to Call a Member Function via a Function Pointer Pin
Jochen Arndt1-Jun-16 22:09
professionalJochen Arndt1-Jun-16 22:09 
SuggestionRe: Syntax of How to Call a Member Function via a Function Pointer Pin
Richard MacCutchan1-Jun-16 22:09
mveRichard MacCutchan1-Jun-16 22:09 
AnswerRe: Syntax of How to Call a Member Function via a Function Pointer Pin
leon de boer4-Jun-16 6:00
Memberleon de boer4-Jun-16 6:00 
As per Jochen's answer but I would also add a guard against your forgetting to set the pointer checking it's not NULL. The typecast and advance definition is also unnecessary unless you actually need the type for something, the pointer will be checked for match when you attempt to set it with or without the typecast.

void MyClass::Act(void* pData){
    if (m_pfnDoSomething) m_pfnDoSomething(pData);
}


Here is a minimalist function ptr .. no need for forward delaration, typedef or even a name of field. All you need is the * dereference before the function ptr name it knows what you are doing from that and really all it needs is what the function looks like so when you try to set it, that it checks for match.
class MyClass{
	void(*MyClass::m_pfnDoSomething)(void*);

	void MyClass::Act(void* pData){
		if (m_pfnDoSomething) m_pfnDoSomething(pData);
	}

};


Finally especially since your in a class I would suggest you don't pass in the void* data pointer but look at other options to typecast or marshal the data in a way that is a little safer.
In vino veritas


modified 4-Jun-16 11:36am.

Questionfor project Pin
Member 125588541-Jun-16 0:22
MemberMember 125588541-Jun-16 0:22 
AnswerRe: for project Pin
CPallini1-Jun-16 0:33
mveCPallini1-Jun-16 0:33 
AnswerRe: for project Pin
Richard MacCutchan1-Jun-16 0:39
mveRichard MacCutchan1-Jun-16 0:39 
QuestionRe: for project Pin
David Crow1-Jun-16 3:50
MemberDavid Crow1-Jun-16 3:50 
AnswerRe: for project Pin
Bram van Kampen1-Jun-16 16:26
MemberBram van Kampen1-Jun-16 16:26 
QuestionHow to determine file offset of each section using RVA in pe file ? Pin
Member 1254265131-May-16 2:26
MemberMember 1254265131-May-16 2:26 
AnswerRe: How to determine file offset of each section using RVA in pe file ? Pin
Richard MacCutchan31-May-16 3:00
mveRichard MacCutchan31-May-16 3:00 
AnswerRe: How to determine file offset of each section using RVA in pe file ? Pin
Bram van Kampen1-Jun-16 16:11
MemberBram van Kampen1-Jun-16 16:11 
QuestionCopy certain member variable data of a structure Pin
manoharbalu31-May-16 0:45
Membermanoharbalu31-May-16 0:45 
AnswerRe: Copy certain member variable data of a structure Pin
Richard MacCutchan31-May-16 1:31
mveRichard MacCutchan31-May-16 1:31 
GeneralRe: Copy certain member variable data of a structure Pin
manoharbalu31-May-16 1:40
Membermanoharbalu31-May-16 1:40 
GeneralRe: Copy certain member variable data of a structure Pin
Richard MacCutchan31-May-16 1:47
mveRichard MacCutchan31-May-16 1:47 
AnswerRe: Copy certain member variable data of a structure Pin
Jochen Arndt31-May-16 2:43
professionalJochen Arndt31-May-16 2:43 
AnswerRe: Copy certain member variable data of a structure Pin
leon de boer31-May-16 4:59
Memberleon de boer31-May-16 4:59 
GeneralRe: Copy certain member variable data of a structure Pin
manoharbalu1-Jun-16 3:25
Membermanoharbalu1-Jun-16 3:25 
GeneralRe: Copy certain member variable data of a structure Pin
Bram van Kampen1-Jun-16 16:51
MemberBram van Kampen1-Jun-16 16:51 
GeneralRe: Copy certain member variable data of a structure Pin
manoharbalu1-Jun-16 21:02
Membermanoharbalu1-Jun-16 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.