In search of understanding a typedef

I have a program where I’m dynamically loading a dll and using a ‘factory’ function to get a class instance. (I actually pulled this from a post I read somewhere on the Net and just blindly used it.) To do this, I have a code snippet like the following:

typedef IHermes* (*pHermesFactory)();

pHermesFactory pHermes = (pHermesFactory)GetProcAddress(hInstance, "HermesFactory");

My question is – what does that last line become after the typedef ‘replacement’? When I tried to figure it out by hand I came up with:

IHermes* (*pHermes)() = (IHermes* (*GetProcAddress(hInstance, "HermesFactory"))();

Does anyone know if this is right? I really don’t NEED to know, but I’d like to understand typedef’s a bit better.

Source: c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.