|
From: Pascal <p.t...@ti...> - 2004-07-07 04:41:39
|
Hello All,
// ------------------------main.h----------------
#include <iostream>
#include <stdlib.h>
class A
{
public:
int f ();
};
int A::f(void)
{
return 5;
};
//----------------------------main.cpp---------------------------------------------
#include "main.h"
using namespace std;
int main(int argc, char *argv[])
{
A cA;
int *pFunc;
*pFunc = cA.f();
// cout << ??? How I can call cA.f() using the
pointer pFunc?
/* Direct Acces to the Function */
printf("printf - f() : %d \t |\t",cA.f());
cout << "COUT - f() : " << cA.f() << endl;
/* Acces with the pointeur *pFunc */
printf("printf - *pFunc : %x\ \t | \t",*pFunc);
cout << "COUT - *pFunc : " << *pFunc << endl;
/* Address of the pointeur *pFunc */
printf("printf - &pFunc : %x\ | \t",&pFunc);
cout << "COUT - &pFunc : " << &pFunc << endl;
system("PAUSE"); return 0;
}
Is that Right?
but how to acces to the Direct Adress of the function f()?
|