PDA

Click to See Complete Forum and Search --> : How to make a class of other people's functions?Source not provided!


transcendental
Dec 15th, 2001, 06:05 AM
Well guys, can I make other functions as my class's member functions? Source code not available to me. Can I do this in order to make a OOP framework out of the APIs.

Izzit as easy as declaring the member functions as extern and include the header?

Or it is not possible?

If it is not possible, I have to make a wrapper class in which its member functions call the APIs.

Any ideas or comments, pls contribute them here....

Thanks.:p

transcendental
Dec 15th, 2001, 06:07 AM
I had a strange feeling that I had just answered my own question.:p

CornedBee
Dec 15th, 2001, 07:25 AM
You did :)
This is a big part of what the MFC does: call API functions from within it's member functions. It is not possible to use the API functions as member functions directly.

Zaei
Dec 15th, 2001, 03:24 PM
Although you CAN fake it:

typedef DWORD TFunc();

class myAPIClass
{
public:
myAPIClass();
TFunc* getTickCount;
};

myAPIClass::myAPIClass()
{
getTickCount = GetTickCount;
}


...
myAPIClass x;
DWORD t;
t = x.getTickCount();


Z.

CornedBee
Dec 19th, 2001, 11:38 AM
Messy: the compiler can't do any type checking at all! Inline wrapper functions are a lot cleaner and the same speed.