Question: What is wrong with the following program? #include int * get _ some _ ints ( ) { std::vector ints = { 1 , 2

What is wrong with the following program?
#include
int *get_some_ints(){
std::vector ints ={1,2,3,4,5};
return ints.data();
}// get_some_ints()
int main(){
int *some_ints = get_some_ints();
delete[] some_ints;
return 0;
}// main()
Group of answer choices
the memory pointed to by some_ints is freed twice
main() leaks the memory pointed to by some_ints
a function cannot return a pointer
some_ints is a pointer and not an array, so delete should be used instead of delete[]
nothing is wrong with this program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!