I want to return an array from a function in C++. I made this simple code to try to achieve it.
#include <iostream>
#include <vector>
std::vector<int> *getx()
{
   std::vector<int> a[2];
   a[0].push_back(0);
   a[1].push_back(1);
   return a;
}
int main()
{
   std::vector<int>* b = getx();
   return 0;
}
It works but I get this Warning:
warning C4172: returning address of local variable or temporary: a
Why if i made std::vector<int> a[2] static I solve the warning?
static std::vector<int> a[2];
Is there another way to return an array from a function without having dangling pointers warnings?
Thank you.
 
     
    