Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
SuggestionRe: CString assignment crashes on Windows 7 Pin
David Crow3-Dec-12 4:08
David Crow3-Dec-12 4:08 
AnswerRe: CString assignment crashes on Windows 7 Pin
CPallini3-Dec-12 4:15
mveCPallini3-Dec-12 4:15 
AnswerRe: CString assignment crashes on Windows 7 Pin
Richard MacCutchan3-Dec-12 5:02
mveRichard MacCutchan3-Dec-12 5:02 
GeneralRe: CString assignment crashes on Windows 7 Pin
pandit843-Dec-12 5:41
pandit843-Dec-12 5:41 
GeneralRe: CString assignment crashes on Windows 7 Pin
Richard MacCutchan3-Dec-12 6:22
mveRichard MacCutchan3-Dec-12 6:22 
AnswerRe: CString assignment crashes on Windows 7 Pin
Stephen Hewitt4-Dec-12 6:34
Stephen Hewitt4-Dec-12 6:34 
GeneralRe: CString assignment crashes on Windows 7 Pin
pandit844-Dec-12 19:44
pandit844-Dec-12 19:44 
GeneralRe: CString assignment crashes on Windows 7 Pin
Stephen Hewitt5-Dec-12 3:49
Stephen Hewitt5-Dec-12 3:49 
AnswerRe: CString assignment crashes on Windows 7 Pin
pandit8418-Dec-12 7:48
pandit8418-Dec-12 7:48 
GeneralRe: CString assignment crashes on Windows 7 Pin
Stephen Hewitt18-Dec-12 17:44
Stephen Hewitt18-Dec-12 17:44 
QuestionSegmentation Fault in GTK library files Pin
SrivathsanRaghavan2-Dec-12 19:20
SrivathsanRaghavan2-Dec-12 19:20 
AnswerRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan2-Dec-12 21:47
mveRichard MacCutchan2-Dec-12 21:47 
GeneralRe: Segmentation Fault in GTK library files Pin
SrivathsanRaghavan2-Dec-12 22:11
SrivathsanRaghavan2-Dec-12 22:11 
GeneralRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan2-Dec-12 22:28
mveRichard MacCutchan2-Dec-12 22:28 
GeneralRe: Segmentation Fault in GTK library files Pin
SrivathsanRaghavan3-Dec-12 0:25
SrivathsanRaghavan3-Dec-12 0:25 
GeneralRe: Segmentation Fault in GTK library files Pin
Richard MacCutchan3-Dec-12 0:55
mveRichard MacCutchan3-Dec-12 0:55 
Questioncan i use mem_fun like this? Pin
Falconapollo1-Dec-12 17:37
Falconapollo1-Dec-12 17: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:

C++
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:

C++
/* 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 20:56
mveRichard MacCutchan1-Dec-12 20:56 
AnswerRe: can i use mem_fun like this? Pin
Stephen Hewitt2-Dec-12 4:45
Stephen Hewitt2-Dec-12 4:45 
AnswerRe: can i use mem_fun like this? Pin
troyxyz2-Dec-12 6:21
troyxyz2-Dec-12 6:21 
AnswerRe: can i use mem_fun like this? Pin
Stefan_Lang3-Dec-12 2:14
Stefan_Lang3-Dec-12 2:14 
AnswerRe: can i use mem_fun like this? Pin
Stefan_Lang3-Dec-12 3:45
Stefan_Lang3-Dec-12 3:45 
GeneralRe: can i use mem_fun like this? Pin
Falconapollo4-Dec-12 14:43
Falconapollo4-Dec-12 14:43 
Questionclient server for running the program Pin
danielsutopo1-Dec-12 15:09
danielsutopo1-Dec-12 15:09 
AnswerRe: client server for running the program Pin
Albert Holguin1-Dec-12 17:22
professionalAlbert Holguin1-Dec-12 17:22 

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.