+ 2
How can I solve this problem ?
I have a class, there is no syntax error, but in line 29 the argument of the function was true, but after the iterations of the for loop the argument value that is assigned to the pointer is not the same, I tried to debug it but I couldn't solve it, I print the Debugging results to make it easier for you. The problems are in lines(29,33), in general there is an issue in their function. (It's not a homework). https://code.sololearn.com/cIwaLhplysTV/?ref=app
12 Respostas
+ 2
The first thing that thise are local variables so automatically go out of scope on function return. No need to delete.
+ 1
Can you break down program to problem lines??
I found only that you are not increasing index values
In
cout<<"Items_Size ="<<items_Size<<endl;
So use
cout<<"Items_Size ="<<items_Size++ <<endl;
+ 1
Jayakrishna🇮🇳
The (items_Size++) is located in the add function in line 68, because the index is used to indicate the items names index and the items password index.
+ 1
It solves the problem but I think it causes a memory leak, why didn't you free up the memory?
https://www.quora.com/In-C-if-I-allocate-new-memory-on-the-heap-using-the-new-function-and-assign-its-address-to-a-pointer-within-a-called-local-function-will-the-pointer-go-out-of-scope-when-the-control-goes-back-to-the-calling-function
+ 1
If I delete it, nothing happens, except that bug, is this a rule?
+ 1
Pointer behave undefinedly if you try to access invalid locations.. I tried many changes to find out that..
0
"Except the bug" Means,? Your program won't running further.. It raise double free() error or core dump error... With some reference, just I came to that, It causing memory leak by delete on invalid pointer....
0
I couldn't get what you mean.
0
Uncomment line 51 and see.. What is output?
0
Jayakrishna🇮🇳
There will be a strange behavior, items_Names takes the values of items_Pass.
0
Bnkf