Skip to main content
gamedev.net
🔒 Locked

vector<function pointer> ?

Started by Vlion 2 replies 950+ views
Original Post
Vlion
Vlion
What''s syntax for a vector of function pointers ? I have this(stub func):
vector operator()(string str)
{
   vector retarray;
   return retarray;
}
 
And the compiler goves me errors. I will be passing in funcs of this form: int f_name(string &, string &, string &) ~V''lion Bugle4d
~V'lionBugle4d
ShoelessManiac
ShoelessManiac
I'm just starting with this programming stuff; but have you tried typedefing the function type and then using it in your code? Like this:

typedef int (* func_ptr)() FUNC_PTR;
vector<FUNC_PTR> operator()(string str)
{
vector<FUNC_PTR> v;
return v;
}

I don't know if this will work; but I have had similar problems.

edit: Hmmm; code tags all mesed up.

[edited by - ShoelessManiac on May 31, 2003 1:23:44 AM]
Zipster
Zipster
It simply doesn''t like the syntax within the brackets.

Try:

typedef int (*MyFunc)(string&,string&,string&);

vector<MyFunc> operator()(string str)
{
vector<MyFunc> retarray;
return retarray;
}


Compiles like a dream for me.
ShoelessManiac
ShoelessManiac
My mistake; I shouldnt have put the FUNC_PTR bit at the end of the typedef.
Good luck friend!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.