Hi.I'm trying to find out the solution of next task:
Create a class that contains a vector of pointers to functions, with add( ) member function to add pointers to functions. Add a run( ) function that moves through the vector and calls all of the functions.
My code have some errors.
#include <iostream>
#include<vector>
using namespace std;
typedef void (*pf)();
class A
{
void add(pf){ v.push_back(pf);}
// Take a simplre class does not have function pointers, but integers
// Does this look sane:
void add( int ) { v.push_back( int );}
No.
Why not a.add( print1 );?
v[i]; returns a pointer. You should dereference it in order to call the function.