Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ syntax Pin
CPallini10-Oct-16 21:49
mveCPallini10-Oct-16 21:49 
AnswerRe: C++ syntax Pin
Richard MacCutchan10-Oct-16 21:50
mveRichard MacCutchan10-Oct-16 21:50 
AnswerRe: C++ syntax Pin
David Crow11-Oct-16 6:20
David Crow11-Oct-16 6:20 
QuestionOne more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_9-Oct-16 6:18
Vaclav_9-Oct-16 6:18 
AnswerRe: One more error using function pointers - void value not ignored as it ought to be Pin
Richard MacCutchan9-Oct-16 6:36
mveRichard MacCutchan9-Oct-16 6:36 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_9-Oct-16 7:53
Vaclav_9-Oct-16 7:53 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer9-Oct-16 23:11
leon de boer9-Oct-16 23:11 
AnswerRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer9-Oct-16 21:42
leon de boer9-Oct-16 21:42 
Sorry to butt in but your problem has nothing to do with classes or inheriting it's just code syntax that would not work anywhere.

Lets review function pointers ..
1.) you can set then to a function using the "&" symbol
2.) you can transfer the value to another function pointer that matches.

Can I suggest you first try and write just two function pointers in normal C++ and try to set them ... here let me write the code for you
 void someFunc (char* text){
     // .... some code in here
}

// Here are our two function pointers
void(*FunctionPointer_A)(char *);
void(*FunctionPointer_B)(char *);

// You can set either of them to the function using the & symbol .. item 1 use of function pointers
FunctionPointer_A = &someFunc;
FunctionPointer_B = &someFunc;

// Or you can set one and copy the other which is item 1 then item 2 use of function pointers
FunctionPointer_A = &someFunc;
FunctionPointer_B = FunctionPointer_A ;

I think this later is what you are attempting to do and if you copy the code in you should find it happily compiles.

Forgetting the class prefix this what you typed is nonsense .. it doesn't meet either of the item 1 or 2 formats
FunctionPointer_B = Process_INHERITANCE_A( Text);


After Richards suggestion you at least seem to get the function pointer setting
FunctionPointer_B = &INHERITANCE_A::Process_INHERITANCE_A;

That I can at least I can understand and is ever so close but now we come details of a class.

Any class function has a hidden self pointer pushed down on the function call. You don't see it the C++
compiler hides the syntax from you. So basically your function pointer doesnt equal the actual function
of a class function .. that is what the compiler is complaining about.

Your function pointer B needs to reflect its a class member function pointer .. not a function pointer to a static code
redefine it to
void(INHERITANCE_A::*FunctionPointer_B)(char *);

You may also need to typedef this if you want to carry the function as a forward declaration

All that is really happening is the function pointer knows to push the class self pointer down before it calls but from
your perspective it makes the compiler see the two as the same type.

There are better ways to do the function pointer assignment for classes, the magic term to do a search for is
memberfunctionpointer. Because you are trying to make a function pointer to a member function in a class.
Try:Member Function Pointers and the Fastest Possible C++ Delegates[^]
In vino veritas


modified 10-Oct-16 4:57am.

GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Richard MacCutchan9-Oct-16 21:49
mveRichard MacCutchan9-Oct-16 21:49 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer9-Oct-16 23:23
leon de boer9-Oct-16 23:23 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Richard MacCutchan9-Oct-16 23:25
mveRichard MacCutchan9-Oct-16 23:25 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_10-Oct-16 4:17
Vaclav_10-Oct-16 4:17 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer10-Oct-16 4:32
leon de boer10-Oct-16 4:32 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_10-Oct-16 13:20
Vaclav_10-Oct-16 13:20 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer10-Oct-16 17:02
leon de boer10-Oct-16 17:02 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_11-Oct-16 7:01
Vaclav_11-Oct-16 7:01 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer11-Oct-16 17:26
leon de boer11-Oct-16 17:26 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
Vaclav_12-Oct-16 14:42
Vaclav_12-Oct-16 14:42 
GeneralRe: One more error using function pointers - void value not ignored as it ought to be Pin
leon de boer12-Oct-16 17:09
leon de boer12-Oct-16 17:09 
QuestionMore basic C++ questions - may I ask? Pin
Vaclav_8-Oct-16 15:24
Vaclav_8-Oct-16 15:24 
AnswerRe: More basic C++ questions - may I ask? Pin
Midi_Mick8-Oct-16 15:52
professionalMidi_Mick8-Oct-16 15:52 
AnswerRe: More basic C++ questions - may I ask? Pin
Richard MacCutchan8-Oct-16 20:37
mveRichard MacCutchan8-Oct-16 20:37 
GeneralRe: More basic C++ questions - may I ask? Pin
Vaclav_9-Oct-16 6:20
Vaclav_9-Oct-16 6:20 
GeneralRe: More basic C++ questions - may I ask? Pin
Richard MacCutchan9-Oct-16 6:27
mveRichard MacCutchan9-Oct-16 6:27 
GeneralRe: More basic C++ questions - may I ask? Pin
Graham Breach9-Oct-16 21:46
Graham Breach9-Oct-16 21:46 

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.