hi im new to c++ and i done a few project's in c# java VB etc and im trying to work out how to get an dynamic array of delegate void methods i have some code in c# to explain what im trying to do and some how convert it to unmanaged c++.
public delegate void Action(List<int> internalcmd, List<byte> initialdata);
public List<Action> commandarray = new List<Action>();
hi im new to c++ and i done a few project's in c# java VB etc and im trying to work out how to get an dynamic array
iv done a little research and you can use vectors instead of list array. but im not too sure about how to use a delegate or function pointer.
What is a "delegate"?
I think you should concentrate on what your application is supposed to do, and rewrite it using C++ instead of trying to translate line-by-line from C# to C++. Doing a line-by-line translation will only get you into trouble, since the languages are not the same and the similar keywords such as "new" do different things and are supposed to be used differently.
A function pointer would do it, but might not be the most flexible solution; it would only accept actual functions, and not functors (which are often more useful).
One means of handling either a function pointer or a functor transparently is to use a template type to represent the thing. However, for a container such as a std::vector, this isn't an option since every element of the vector must have the same type.
If you have access to Boost, then the boost::function library provides a solution to the problem. If not, you can probably duplicate that functionality to a limited extent without too much trouble, something like