I am trying to copy a binary tree in a c++ vector and i am having a kind of error that I cant find where it is generated. This i in the header file (.h)
struct NyjePeme
{
  int Key;
  NyjePeme *left = NULL;
  NyjePeme *right = NULL;
};
class PemeKerkimi
{
  private:
  NyjePeme *root;
public:
  PemeKerkimi();
  ~PemeKerkimi();
And there are the methods i have used in .cpp file:
void ASCVektor(vector<int> v)
{
  int i, j;
  for (i = 0; i < v.size() - 1; i++)
{
    for (j = i + 1; j < v.size(); j++)
    {
        if (v[i] > v[j])
        {
            int tmp = v[i];
            v[i] = v[j];
            v[j] = tmp;
        }
    }
   }
}
void printVektor(vector<int> v)
{
  int i;
  for (i = 0; i < v.size(); i++)
  {
    cout << v[i] << ", ";
  }
  cout << endl;
}
void copyTreeinVector(NyjePeme *T, vector<int> v)
{
  if (T != NULL)
  {
    copyTreeinVector(T->left, v);
    v.push_back(T->Key);
    copyTreeinVector(T->right, v);
    return;
  }
  return;
}
NyjePeme *PemeKerkimi::TheKSmallestElement(int k)
{
   vector<int> v;
   coptyTreeinVector(root, v);
   ASCVektor(v);
...
   
The problem is in copyTreeinVector() function and the error message is this:
Process returned -1073741819 (0xC0000005) and it takes a while to throw that message. I searched about that error and it is generated due to bad use of pointers... but I cant find the problem in my code
 
    