+ 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

19th Apr 2022, 9:38 PM
Mohammed
12 ответов
+ 2
The first thing that thise are local variables so automatically go out of scope on function return. No need to delete.
20th Apr 2022, 12:58 PM
Jayakrishna 🇮🇳
+ 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;
19th Apr 2022, 9:47 PM
Jayakrishna 🇮🇳
+ 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.
19th Apr 2022, 9:56 PM
Mohammed
20th Apr 2022, 9:27 AM
Jayakrishna 🇮🇳
+ 1
If I delete it, nothing happens, except that bug, is this a rule?
20th Apr 2022, 1:03 PM
Mohammed
+ 1
Pointer behave undefinedly if you try to access invalid locations.. I tried many changes to find out that..
20th Apr 2022, 2:48 PM
Jayakrishna 🇮🇳
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....
20th Apr 2022, 1:15 PM
Jayakrishna 🇮🇳
0
I couldn't get what you mean.
20th Apr 2022, 1:17 PM
Mohammed
0
Uncomment line 51 and see.. What is output?
20th Apr 2022, 2:35 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 There will be a strange behavior, items_Names takes the values of items_Pass.
20th Apr 2022, 2:39 PM
Mohammed
0
Bnkf
21st Apr 2022, 5:14 PM
Kumar Karampudi