3,976 questions
It is better to make this a templated static member. The array can then be passed in as a parameter.
class path
{
public:
template <unsigned int N>
static int do_stuff(path(&paths)[N])
{
return paths[0].id;
}
private:
int r;
int id;
};
int wmain()
{
path paths[20];
path::do_stuff(paths);
return 0;
}
It would be even better to not use C style arrays and instead use std::array or std::vector.