0

What is the issue when this message come out ?

free(): double free detected in tcache 2 timeout: the monitored command dumped core ./Playground/runner.sh: line 84: 11 Aborted timeout "$runtime" "$output" - < "/usercode/inputFile" ??? What is the meaning of this message ? The code is working but some part of the code doesn’t work and it showing this message ? Help me please 🌹 https://code.sololearn.com/chMqAVL7Bv0s/?ref=app The friend function of ( increment_price ) not working

14th Jul 2020, 3:50 AM
غانم المنصوري
غانم المنصوري - avatar
4 Respostas
+ 5
I'm not familiar with pointers, so my answer might be wrong. The reason for this is freeing a pointer which is already freed and lead to corruption. In increment_price(), you pass the arguments with copy, so the car inside of it has the same information, including pointer members. And when the destructor of the car in the function is called. The pointer members are freed. Because they hold the same address, when the function ends, the members are freed. When the whole program ends, the destructor is called again and try to free the freed members, error occurs. Pass the arguments by reference or make your own copy construtor can solve the problems. Once again. I'm not familiar with pointers and that just a guess. It may not be correct.
14th Jul 2020, 5:10 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 6
Can you please attach your code
14th Jul 2020, 3:52 AM
Atul
Atul - avatar
+ 1
Thank you CarrieForle, the problem has been solved. Maybe the problem is showing just in this phone application, I will try with my laptop CodeBlocks same old code and I will see.🌹🌹 Because I saw one of my friends wrote same code in his laptop with CodeBlocks same all steps and it was working well with out any issue. Thank you so much for your help and your time 🌹🌹
14th Jul 2020, 6:30 AM
غانم المنصوري
غانم المنصوري - avatar
0
Solve of the problem is : we should passing the arguments by reference just, in the friend function ... increment_price (car& c ) and also in the prototype of the function friend that we put it inside the calss. friend int increment_price(car&)
14th Jul 2020, 7:29 AM
غانم المنصوري
غانم المنصوري - avatar