Either you need to declare the first parameter as having the referenced type std::vector<int> & like
void function( std::vector<int> &tab, int n);
Or you should redefine the function such a way that it will return a vector.
Here is a demonstration program.
#include <iostream>
#include <vector>
std::vector<int> function( int n )
{
    std::vector<int> v;
    return n > 0 ? v = function( n - 1 ), v.push_back( n ), v : v;
}
int main()
{
    auto v = function( 10 );
    for (auto &item : v)
    {
        std::cout << item << ' ';
    }
    std::cout << '\n';
}
The program output is
1 2 3 4 5 6 7 8 9 10