What are the issues with the following function void foobari
     What are the issues with the following function?  void foobar(){int x=10;  int* q=&x;  int* p=new int[5];  delete q;  delete &x;}![What are the issues with the following function? void foobar(){int x=10; int* q=&x; int* p=new int[5]; delete q; delete &x;}SolutionGiven Function is v  What are the issues with the following function? void foobar(){int x=10; int* q=&x; int* p=new int[5]; delete q; delete &x;}SolutionGiven Function is v](/WebImages/7/what-are-the-issues-with-the-following-function-void-foobari-990963-1761509563-0.webp) 
  
  Solution
Given Function is
 void foobar()
 {
 int x=10; //Here we are Initializing the value of x
 int* q=&x;Here we are assigning x value to q i.e q=10
 int* p=new int[5];//here p value is zero
 delete q;// this statement deletes the q value
 delete &x;// this statement deletes the &x value
 }
The above function causes Run time error because after Initializing x value & assigning &x value to q we are deleting both values so it leads to Runtime error.
![What are the issues with the following function? void foobar(){int x=10; int* q=&x; int* p=new int[5]; delete q; delete &x;}SolutionGiven Function is v  What are the issues with the following function? void foobar(){int x=10; int* q=&x; int* p=new int[5]; delete q; delete &x;}SolutionGiven Function is v](/WebImages/7/what-are-the-issues-with-the-following-function-void-foobari-990963-1761509563-0.webp)
