Click here to Skip to main content
15,907,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Compression/Decompression of Byteblocks Pin
Larry Antram17-Dec-02 13:09
Larry Antram17-Dec-02 13:09 
GeneralRe: Compression/Decompression of Byteblocks Pin
Scott H. Settlemier17-Dec-02 16:31
Scott H. Settlemier17-Dec-02 16:31 
GeneralCListCtrl and WM_LBUTTONUP Pin
Taka Muraoka17-Dec-02 12:33
Taka Muraoka17-Dec-02 12:33 
GeneralRe: CListCtrl and WM_LBUTTONUP Pin
Chris Richardson17-Dec-02 13:44
Chris Richardson17-Dec-02 13:44 
GeneralRe: CListCtrl and WM_LBUTTONUP Pin
Taka Muraoka17-Dec-02 13:50
Taka Muraoka17-Dec-02 13:50 
GeneralRe: CListCtrl and WM_LBUTTONUP Pin
Chris Richardson17-Dec-02 14:48
Chris Richardson17-Dec-02 14:48 
GeneralRe: CListCtrl and WM_LBUTTONUP Pin
Taka Muraoka17-Dec-02 14:59
Taka Muraoka17-Dec-02 14:59 
GeneralStoopid funcptr question Pin
Klaus Probst17-Dec-02 11:28
Klaus Probst17-Dec-02 11:28 
Consider the following code:

typedef DWORD (FUNCPROC CommandProcPtr)(TCHAR*, TCHAR*, TCHAR*, LPVOID);

typedef std::pair<int, CommandProcPtr*> _vfpt;
typedef std::vector<_vfpt> _vtbl;

_vtbl vtbl;

vtbl.push_back(_vfpt(1,&Functions::_CommandProc1));
vtbl.push_back(_vfpt(2,&Functions::_CommandProc2));
vtbl.push_back(_vfpt(3,&Functions::_CommandProc3));

for (int i = 0; i < 3; i++)
{
	char szArg[20];
	sprintf(szArg, "Call number %i", i);

	char szFlags[20];
	sprintf(szFlags, "/exec /%i", i + 2);

	char szCommand[20];
	sprintf(szCommand, "Command%i", i * 3);
	
	(*vtbl[i].second)(szCommand, szArg, szFlags, NULL);

}

Now, the bit where the function is invoked through the pointer:
(*vtbl[i].second)(szCommand, szArg, szFlags, NULL);

puzzles me (eh). Why does this:
(vtbl[i].second)(szCommand, szArg, szFlags, NULL);

work as well? (notice I'm not dereferencing std::pair.second there)
I'm sure there's some stoopid explanation and I'm just being dense, but I can't see why both versions would work? Or is there no difference between the two?

___________
Klaus
[vbbox.com]
GeneralRe: Stoopid funcptr question Pin
Taka Muraoka17-Dec-02 11:50
Taka Muraoka17-Dec-02 11:50 
GeneralRe: Stoopid funcptr question Pin
Michael Dunn17-Dec-02 16:01
sitebuilderMichael Dunn17-Dec-02 16:01 
GeneralRe: Stoopid funcptr question Pin
Klaus Probst17-Dec-02 18:08
Klaus Probst17-Dec-02 18:08 
GeneralRe: Stoopid funcptr question Pin
Taka Muraoka17-Dec-02 18:14
Taka Muraoka17-Dec-02 18:14 
GeneralMDI Question.... Pin
Ryan B.17-Dec-02 10:33
Ryan B.17-Dec-02 10:33 
GeneralRe: MDI Question.... Pin
Gary Kirkham17-Dec-02 11:04
Gary Kirkham17-Dec-02 11:04 
GeneralShellExecute Question. (urgent) Pin
RickGavin17-Dec-02 10:12
RickGavin17-Dec-02 10:12 
GeneralRe: ShellExecute Question. (urgent) Pin
Nish Nishant17-Dec-02 14:13
sitebuilderNish Nishant17-Dec-02 14:13 
GeneralRe: ShellExecute Question. (urgent) Pin
Michael Dunn17-Dec-02 16:04
sitebuilderMichael Dunn17-Dec-02 16:04 
GeneralRe: ShellExecute Question. (urgent) Pin
RickGavin17-Dec-02 18:24
RickGavin17-Dec-02 18:24 
GeneralDumb OnSaveDocument question.. Pin
RobJones17-Dec-02 9:30
RobJones17-Dec-02 9:30 
GeneralRe: Dumb OnSaveDocument question.. Pin
lucy17-Dec-02 9:44
lucy17-Dec-02 9:44 
GeneralRe: Dumb OnSaveDocument question.. Pin
RobJones17-Dec-02 9:46
RobJones17-Dec-02 9:46 
GeneralRe: Dumb OnSaveDocument question.. Pin
lucy17-Dec-02 9:53
lucy17-Dec-02 9:53 
GeneralRe: Dumb OnSaveDocument question.. Pin
RobJones17-Dec-02 10:03
RobJones17-Dec-02 10:03 
GeneralRe: Dumb OnSaveDocument question.. Pin
RobJones17-Dec-02 10:09
RobJones17-Dec-02 10:09 
Questionhow to derive a CArray method Pin
lucy17-Dec-02 8:26
lucy17-Dec-02 8:26 

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.