A typedef in its most literal sense is an alias. It's a way of saying 'when I use this type, I actually mean this other type'.
I think in your examples are confusing you a bit because you're typedef'ing function pointers, which might look a little different.
Basically, typedef syntax is:
typedef <some_existing_type> <my_aliased_type>;
A concrete example might be something like:
typedef std::vector<MyNamespace::MyObject> TMyObjectVector;
This might help to make your code a little more readable. Say you declare an iterator for that vector type. Let's look at typedef'd vs non-typedef'd:
1 2 3 4 5
|
// No typedef
std::vector<MyNamespace::MyObject>::iterator iter;
// Typedef
TMyObjectVector::iterator iter;
|
You can freely use your typedef'd alias wherever you want.
1 2 3 4 5
|
// This...
void DoSomethingToThisVector(std::vector<MyNamespace::MyObject>& myVector);
// Could be written like this...
void DoSomethingToThisVector(TMyObjectVector& myVector);
|
As for function pointers, the syntax is:
<return type> (*<identifier>)(parameter types, ...)
So a function pointer to a function returning a std::string and taking a couple of integers would be:
std::string (*myFunctionPointer)(int, int)
When you typedef a function pointer, the identifier portion of the above syntax is what actually because the alias:
1 2 3 4 5 6 7
|
typedef std::string(*TMyFunctionPointer)(int, int);
// This...
TMyFunctionPointer somePointer = SomeFunction;
// Is the same as writing this...
std::string (*somePointer) (int, int) = SomeFunction;
|
So, say you've typedef'd your function pointer, you can now use your freely, just like the vector example above.
1 2 3 4 5
|
// This...
void SomeFunctionThatTakesAFunctionPointer(std::string(*myFunctionPointer)(int a, int b));
// Can be written like this...
void SomeFunctionThatTakesAFunctionPointer(TMyFunctionPointer myFunctionPointer);
|
A full example:
https://ideone.com/tNRIL3
Hope this helps.
Edit: To answer the case you've specified in your post, this declares a typedef'd alias to a function pointer that points to a function that returns a bool and takes an integer. The name of this alias is ValidationMethod.