Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IWebBrowser2 and Document Pin
Philip Patrick20-May-02 20:53
professionalPhilip Patrick20-May-02 20:53 
QuestionTabbed CView ala Excel? Pin
Robert Vista20-May-02 11:48
Robert Vista20-May-02 11:48 
QuestionPress enter in combobox? Pin
20-May-02 11:11
suss20-May-02 11:11 
AnswerRe: Press enter in combobox? Pin
James R. Twine20-May-02 11:14
James R. Twine20-May-02 11:14 
Generalstd::string transformation Pin
Carlos Sánchez García20-May-02 10:54
Carlos Sánchez García20-May-02 10:54 
GeneralRe: std::string transformation Pin
Joaquín M López Muñoz20-May-02 11:08
Joaquín M López Muñoz20-May-02 11:08 
GeneralRe: std::string transformation Pin
Joaquín M López Muñoz20-May-02 21:03
Joaquín M López Muñoz20-May-02 21:03 
GeneralPointer to member function Pin
Aaron Schaefer20-May-02 10:50
Aaron Schaefer20-May-02 10:50 
Hi All,

I would like to find an example of declaring a pointer to a member function. I would like to be able to call member functions of a derived class, by name, through a pointer to a base class. Something like this:

CBase
{
// A member function that takes no args . . .
typedef ??? MemberFunctionPointer
double Calculation(const std::string& idx)
{
if(m_map.end() == m_map.find(idx))
return; // No such function

MemberFunctionPointer func = m_map(idx);
double result = *function;
}
void RegisterFunction(const std::string& strName, MemberFunctionPoint pFunc)
{
m_map[strName] = pFunc;
}
}

class CTrig : public CBase
{
double pi {return 3.1415;}

CTrig()
{
CBase::RegisterFunction("pi", this->pi);
}
}

CBase* pBase = new CTrig;
double result = pBase->Calculation("pi");

So how about it? What should the typedef look like?

Thanks,

Aaron
GeneralRe: Pointer to member function Pin
Joaquín M López Muñoz20-May-02 10:58
Joaquín M López Muñoz20-May-02 10:58 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 3:34
Aaron Schaefer21-May-02 3:34 
GeneralRe: Pointer to member function Pin
Chris Losinger20-May-02 11:04
professionalChris Losinger20-May-02 11:04 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 3:31
Aaron Schaefer21-May-02 3:31 
GeneralRe: Pointer to member function Pin
Chris Losinger21-May-02 5:40
professionalChris Losinger21-May-02 5:40 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 7:07
Aaron Schaefer21-May-02 7:07 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 7:09
Aaron Schaefer21-May-02 7:09 
GeneralRe: Pointer to member function Pin
Chris Losinger21-May-02 8:09
professionalChris Losinger21-May-02 8:09 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 8:17
Aaron Schaefer21-May-02 8:17 
GeneralRe: Pointer to member function Pin
James R. Twine20-May-02 11:00
James R. Twine20-May-02 11:00 
GeneralRe: Pointer to member function Pin
Ernest Laurentin20-May-02 11:14
Ernest Laurentin20-May-02 11:14 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 3:33
Aaron Schaefer21-May-02 3:33 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 3:40
Aaron Schaefer21-May-02 3:40 
GeneralRe: Pointer to member function Pin
hex20-May-02 16:18
hex20-May-02 16:18 
GeneralRe: Pointer to member function Pin
Aaron Schaefer21-May-02 3:42
Aaron Schaefer21-May-02 3:42 
GeneralSetItemData() and DWORD_PTR Pin
dazinith20-May-02 10:37
dazinith20-May-02 10:37 
GeneralRe: SetItemData() and DWORD_PTR Pin
Joaquín M López Muñoz20-May-02 10:51
Joaquín M López Muñoz20-May-02 10:51 

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.