무작위임
https://stackoverflow.com/a/2236227/17522808
static const int arr[] = {16,2,77,29};
vector<int> vec (arr, arr + sizeof(arr) / sizeof(arr[0]) );
typedef std::vector<Account::t> accounts_t;
int const amounts[] = { 42, 54, 957, 432, 1234, 0, 754, 16576 };
size_t const amounts_size( sizeof(amounts) / sizeof(int) );
accounts_t accounts( amounts, amounts + amounts_size );
void test1();
void test2(); /* Prototypes */
void test3();
/* array with three functions */
void (*functptr[])() = { test1, test2, test3 } ;
만약 클레스의 함수들이라면,
hpp file
#ifndef HARL_CLASS_H
# define HARL_CLASS_H
class Harl
{
private:
void test1( void );
void test2( void );
void test3( void );
public:
Harl();
~Harl();
};
#endif
cpp file
#include "Harl.cpp"
int main()
{
void (Harl::*funcptr[]) (void ) { &Harl::test1, &Harl::test2, &Harl::test3 }
for (int i = 0; i < 3; i++)
{
*funcptr[i]();
}
}