Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralQuestion on VC++ and MS Word Pin
skinnyreptile29-Jan-04 9:39
skinnyreptile29-Jan-04 9:39 
GeneralRe: Question on VC++ and MS Word Pin
basementman30-Jan-04 10:25
basementman30-Jan-04 10:25 
QuestionOutlook 2003 contact like grid control? Pin
Joe Woodbury29-Jan-04 9:35
professionalJoe Woodbury29-Jan-04 9:35 
AnswerRe: Outlook 2003 contact like grid control? Pin
Antti Keskinen29-Jan-04 10:29
Antti Keskinen29-Jan-04 10:29 
GeneralRe: Outlook 2003 contact like grid control? Pin
Joe Woodbury29-Jan-04 11:11
professionalJoe Woodbury29-Jan-04 11:11 
AnswerRe: Outlook 2003 contact like grid control? Pin
Ivor S. Sargoytchev29-Jan-04 11:32
Ivor S. Sargoytchev29-Jan-04 11:32 
GeneralPassing WndProc as a method parameter (Function Pointers Pin
Senkwe Chanda29-Jan-04 9:18
Senkwe Chanda29-Jan-04 9:18 
GeneralRe: Passing WndProc as a method parameter (Function Pointers Pin
Antti Keskinen29-Jan-04 10:57
Antti Keskinen29-Jan-04 10:57 
What you are passing here is a pointer to a function. The name of a function is always it's address, like using the address-of operator automatically. This address, of course, refers to the starting point of the function in memory.

However, in this case, the constructor seems to create a copy of the function, and move it into a seperate place in memory. I do not know why it does this, but calling the function does work properly. Here is the code fragment with which I tested it.
#include <iostream>
using namespace std;<DIV>

typedef void (*ptrFunc1)(int, int, double, double);<DIV>

void MyFunction( int a, int b, double c, double d )
{
	cout << "Inserted: " << a << " " << b << " " << c << " " << d << "\n\n";
}<DIV>

class Nothing
{
public:
	Nothing(ptrFunc1 func1);
};<DIV>

Nothing::Nothing(ptrFunc1 func1)
{
	int a = 10;
	int b = 20;
	double c = 30;
	double d = 40;<DIV>

	func1(a, b, c, d);
}<DIV>

int main(void)
{
	Nothing MyNothing(MyFunction);
}
Although whilst in debugging, the addresses of MyFunction and func1 are different, and even (*func1) points to a different place than MyFunction, the code calls MyFunction properly through the func1 function pointer, and the text gets printed out correctly.

I see no reason why your implementation would not work properly as well. The reasons of why the memory locations are different is unknown to me, it would require some more work to determine it. I even tested it by creating two objects of class Nothing. In that case, the func1 pointed to the same location in both cases.

So, although I don't understand why it happens, the code works, so you shouldn't have anything to worry on that part Smile | :)

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
Questioncan i use two projects in one work space ,, how ??? Pin
Zeeshan Bilal29-Jan-04 8:45
Zeeshan Bilal29-Jan-04 8:45 
AnswerRe: can i use two projects in one work space ,, how ??? Pin
Antti Keskinen29-Jan-04 11:06
Antti Keskinen29-Jan-04 11:06 
AnswerRe: can i use two projects in one work space ,, how ??? Pin
Mukkie29-Jan-04 11:07
Mukkie29-Jan-04 11:07 
Questioni want to send my char array of 1 MB through CSocket .. it Contains Sound data. How i typecast it or ,,,,,? Pin
Anonymous29-Jan-04 8:41
Anonymous29-Jan-04 8:41 
AnswerRe: i want to send my char array of 1 MB through CSocket .. it Contains Sound data. How i typecast it or ,,,,,? Pin
Dean Goodman29-Jan-04 8:56
Dean Goodman29-Jan-04 8:56 
GeneralProblem with ListCtrl on Windows 98 Pin
Brigg Thorp29-Jan-04 8:31
Brigg Thorp29-Jan-04 8:31 
GeneralRe: Problem with ListCtrl on Windows 98 Pin
Nick Nougat30-Jan-04 5:15
Nick Nougat30-Jan-04 5:15 
GeneralMDI question.. Pin
RobJones29-Jan-04 8:14
RobJones29-Jan-04 8:14 
GeneralNever Mind.. Figured it out.. Pin
RobJones29-Jan-04 8:24
RobJones29-Jan-04 8:24 
GeneralLink Error LNK2019 which makes no sense! Pin
bneacetp29-Jan-04 7:33
bneacetp29-Jan-04 7:33 
GeneralRe: Link Error LNK2019 which makes no sense! Pin
ZoogieZork29-Jan-04 8:58
ZoogieZork29-Jan-04 8:58 
GeneralRe: Link Error LNK2019 which makes no sense! Pin
bneacetp29-Jan-04 10:04
bneacetp29-Jan-04 10:04 
GeneralVS.Net2k3 prob: links, but doesn't create .lib Pin
Steve The Plant29-Jan-04 6:52
Steve The Plant29-Jan-04 6:52 
GeneralRe: VS.Net2k3 prob: links, but doesn't create .lib Pin
Dean Goodman29-Jan-04 8:16
Dean Goodman29-Jan-04 8:16 
GeneralRe: VS.Net2k3 prob: links, but doesn't create .lib Pin
Steve The Plant29-Jan-04 8:25
Steve The Plant29-Jan-04 8:25 
GeneralRe: VS.Net2k3 prob: links, but doesn't create .lib Pin
Antti Keskinen29-Jan-04 11:23
Antti Keskinen29-Jan-04 11:23 
GeneralDragging files from my app to the Recycle-Bin, no result Pin
ohadp29-Jan-04 6:14
ohadp29-Jan-04 6:14 

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.