Can someone interpret this line of code for me?

Started by
3 comments, last by Saruman 17 years, 7 months ago
The following line of code is compilable (if thats a word). It is a constructor to a class. I am just lookin for someone to break down the "english" composion of it (...a function that takes an argument of X of type Y, another argument....ect). I posted my beliefs of what what it is, but I need someone to confirm or tell me what it is if I am wrong.

ResourceManager( void (*CreateResourceFunction)( Type **resource, char *name, char *path ) = NULL )
 {
		m_list = new LinkedList< Type >;

		CreateResource = CreateResourceFunction

My interpretation: Contructor named ResourceManager that takes the arguments: 1) A pointer to a function with a return type of void which it takes the arguments of 1a)?????? Type **resource 1b) a pointer named name of type char 1c) a pointer named path of type char
Advertisement
I am guessing this is a template class/function and type is your typename? It looks exactly as you have specified, a constructor that takes a function pointer argument that has three arguments.
Hi.

ResourceManager is a function (probably a class function or a constructor) that takes in a single parameter. That parameter is a function pointer for a function that takes in 3 parms. The '= NULL' means that the CreateResourceFunction parameter has a defaul value of NULL.

Steve
thanks all
Also that is more C style development so if you are using C++ (which you don't mention so I am just guessing) I would heavily suggest using Functors.

This topic is closed to new replies.

Advertisement