Click here to Skip to main content
15,506,675 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: [edited]Re: pointers to functions Pin
Mircea Neacsu16-Jul-22 5:26
mvaMircea Neacsu16-Jul-22 5:26 
GeneralRe: [edited]Re: pointers to functions Pin
Calin Negru16-Jul-22 5:40
Calin Negru16-Jul-22 5:40 
GeneralRe: [edited]Re: pointers to functions Pin
Richard MacCutchan16-Jul-22 5:56
mveRichard MacCutchan16-Jul-22 5:56 
GeneralRe: [edited]Re: pointers to functions Pin
Calin Negru16-Jul-22 6:50
Calin Negru16-Jul-22 6:50 
GeneralRe: [edited]Re: pointers to functions Pin
Richard MacCutchan16-Jul-22 7:01
mveRichard MacCutchan16-Jul-22 7:01 
GeneralRe: [edited]Re: pointers to functions Pin
Calin Negru16-Jul-22 7:57
Calin Negru16-Jul-22 7:57 
GeneralRe: [edited]Re: pointers to functions Pin
Richard MacCutchan16-Jul-22 21:58
mveRichard MacCutchan16-Jul-22 21:58 
AnswerRe: pointers to functions Pin
Greg Utas16-Jul-22 8:36
mveGreg Utas16-Jul-22 8:36 
You're creating a pointer to a free function (one defined outside a class) and then storing it, and invoking it, from within an object. But it's also possible to create a pointer to class member data or a member function. See here[^]. You may need to read several articles about this to gain a good understanding, because I can't point to one that is really good on its own. Search on "C++ pointer to member" and read articles that discuss the type Class::* (a pointer to a class member) and operators .* and ->*. These make the following possible:

C++
int Class::* pm = &Class::m;         // pointer to member data "int m"
int (Class::* pf)(int) = &Class::f;  // pointer to member function "int f(int)"
Class c, *k;
c.*pm = 1;        // c.m = 1;
n = c.*pf(0);     // n = c.f(0);
k->.pm = 2;       // k->m = 2;
n = (k->*pf)(0);  // n = k->f(0);  note that ->* requires parentheses

Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.

QuestionConvert decimal to binary in C Pin
sahil Ranka14-Jul-22 2:14
sahil Ranka14-Jul-22 2:14 
AnswerRe: Convert decimal to binary in C Pin
Mircea Neacsu14-Jul-22 2:25
mvaMircea Neacsu14-Jul-22 2:25 
AnswerRe: Convert decimal to binary in C Pin
Richard MacCutchan14-Jul-22 2:29
mveRichard MacCutchan14-Jul-22 2:29 
GeneralRe: Convert decimal to binary in C Pin
sahil Ranka14-Jul-22 3:42
sahil Ranka14-Jul-22 3:42 
AnswerRe: Convert decimal to binary in C Pin
CPallini14-Jul-22 3:36
mveCPallini14-Jul-22 3:36 
GeneralRe: Convert decimal to binary in C Pin
sahil Ranka14-Jul-22 3:42
sahil Ranka14-Jul-22 3:42 
GeneralRe: Convert decimal to binary in C Pin
CPallini14-Jul-22 4:14
mveCPallini14-Jul-22 4:14 
AnswerRe: Convert decimal to binary in C Pin
Richard MacCutchan14-Jul-22 22:15
mveRichard MacCutchan14-Jul-22 22:15 
QuestionPrey/predator c++ project Pin
sahil Ranka12-Jul-22 1:26
sahil Ranka12-Jul-22 1:26 
AnswerRe: Prey/predator c++ project Pin
Richard MacCutchan12-Jul-22 1:29
mveRichard MacCutchan12-Jul-22 1:29 
AnswerRe: Prey/predator c++ project Pin
Greg Utas12-Jul-22 2:20
mveGreg Utas12-Jul-22 2:20 
QuestionHow to share a pointer between an EXE and a DLL Pin
Mircea Neacsu11-Jul-22 14:50
mvaMircea Neacsu11-Jul-22 14:50 
QuestionRe: How to share a pointer between an EXE and a DLL Pin
CPallini11-Jul-22 21:12
mveCPallini11-Jul-22 21:12 
AnswerRe: How to share a pointer between an EXE and a DLL Pin
Mircea Neacsu12-Jul-22 5:01
mvaMircea Neacsu12-Jul-22 5:01 
GeneralRe: How to share a pointer between an EXE and a DLL Pin
Victor Nijegorodov12-Jul-22 7:22
Victor Nijegorodov12-Jul-22 7:22 
GeneralRe: How to share a pointer between an EXE and a DLL Pin
Mircea Neacsu12-Jul-22 8:52
mvaMircea Neacsu12-Jul-22 8:52 
GeneralRe: How to share a pointer between an EXE and a DLL Pin
Victor Nijegorodov12-Jul-22 9:04
Victor Nijegorodov12-Jul-22 9:04 

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.