Click here to Skip to main content
13,405,744 members (55,901 online)

C / C++ / MFC

 
GeneralRe: CString assignment crashes on Windows 7 Pin
Stephen Hewitt18-Dec-12 18:44
memberStephen Hewitt18-Dec-12 18:44 
QuestionSegmentation Fault in GTK library files Pin
SrivathsanRaghavan2-Dec-12 20:20
memberSrivathsanRaghavan2-Dec-12 20:20 
AnswerRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan2-Dec-12 22:47
mvpRichard MacCutchan2-Dec-12 22:47 
GeneralRe: Segmentation Fault in GTK library files Pin
SrivathsanRaghavan2-Dec-12 23:11
memberSrivathsanRaghavan2-Dec-12 23:11 
GeneralRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan2-Dec-12 23:28
mvpRichard MacCutchan2-Dec-12 23:28 
GeneralRe: Segmentation Fault in GTK library files Pin
SrivathsanRaghavan3-Dec-12 1:25
memberSrivathsanRaghavan3-Dec-12 1:25 
GeneralRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan3-Dec-12 1:55
mvpRichard MacCutchan3-Dec-12 1:55 
Questioncan i use mem_fun like this? Pin
Falconapollo1-Dec-12 18:37
memberFalconapollo1-Dec-12 18:37 
I want to set the function pointer at runtime. But i'm stuck here. When i use global function or static class member function, everything is ok. but, when the function is ordinary class member functions. i always got compiler errors. Here is the code:

class A   
{
    int val;
public:
    A() { val = 0; }
    A(int j) { val = j; }

    int aFun(int k) {val -= k; return val; }
};

typedef int (* func)(int );
class B
{
    func m_addr;
public:
    B(func param)
        : m_addr(param)
    {

    }
    void execute()
    {
        cout << m_addr(9) << endl;
    }
};


I'm trying to use them like this:

/* error C2355: 'this' : can only be referenced inside non-static member functions error C2064: term does not evaluate to a function taking 1 arguments class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments */
A a;
B b(A::aFun); 
b.execute();


after googled a lot, i found that std::mem_fun may be helpful. but i don't know how to use it. anyone can help me?

PS: i'm using Visual C++ 2010
AnswerRe: can i use mem_fun like this? Pin
Richard MacCutchan1-Dec-12 21:56
mvpRichard MacCutchan1-Dec-12 21:56 
AnswerRe: can i use mem_fun like this? Pin
Stephen Hewitt2-Dec-12 5:45
memberStephen Hewitt2-Dec-12 5:45 
AnswerRe: can i use mem_fun like this? Pin
goumuli2-Dec-12 7:21
groupgoumuli2-Dec-12 7:21 
AnswerRe: can i use mem_fun like this? Pin
Stefan_Lang3-Dec-12 3:14
memberStefan_Lang3-Dec-12 3:14 
AnswerRe: can i use mem_fun like this? Pin
Stefan_Lang3-Dec-12 4:45
memberStefan_Lang3-Dec-12 4:45 
GeneralRe: can i use mem_fun like this? Pin
Falconapollo4-Dec-12 15:43
memberFalconapollo4-Dec-12 15:43 
Questionclient server for running the program Pin
danielsutopo1-Dec-12 16:09
memberdanielsutopo1-Dec-12 16:09 
AnswerRe: client server for running the program Pin
Albert Holguin1-Dec-12 18:22
memberAlbert Holguin1-Dec-12 18:22 
QuestionLimiting selected checkbox items in a CListCtrl Pin
softwaremonkey1-Dec-12 2:40
membersoftwaremonkey1-Dec-12 2:40 
SuggestionRe: Limiting selected checkbox items in a CListCtrl Pin
DavidCrow1-Dec-12 4:51
memberDavidCrow1-Dec-12 4:51 
AnswerRe: Limiting selected checkbox items in a CListCtrl Pin
Jochen Arndt2-Dec-12 0:56
memberJochen Arndt2-Dec-12 0:56 
GeneralRe: Limiting selected checkbox items in a CListCtrl Pin
softwaremonkey2-Dec-12 23:45
membersoftwaremonkey2-Dec-12 23:45 
QuestionUsing VISUAL C++ 6.0 with OLE Pin
ForNow30-Nov-12 10:06
memberForNow30-Nov-12 10:06 
AnswerRe: Using VISUAL C++ 6.0 with OLE Pin
jschell30-Nov-12 11:46
memberjschell30-Nov-12 11:46 
SuggestionRe: Using VISUAL C++ 6.0 with OLE Pin
DavidCrow30-Nov-12 15:24
memberDavidCrow30-Nov-12 15:24 
GeneralRe: Using VISUAL C++ 6.0 with OLE Pin
ForNow4-Dec-12 14:48
memberForNow4-Dec-12 14:48 
AnswerRe: Using VISUAL C++ 6.0 with OLE Pin
Stephen Hewitt2-Dec-12 5:54
memberStephen Hewitt2-Dec-12 5:54 

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.


Advertise | Privacy |
Web02 | 2.8.180221.1 | Last Updated 22 Feb 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid