Can someone fix my c++ code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone fix my c++ code?

my c++ code has a warning and I don't know how to fix it https://code.sololearn.com/cQFeNHoozZi5/?ref=app

11th Feb 2023, 9:59 AM
Gibran Daffa
Gibran Daffa - avatar
9 Answers
+ 6
Gibran Daffa Then you could use something like bool & return false instead. But I don't think NULL will work in this context. https://stackoverflow.com/questions/67347566/how-to-properly-return-null-empty-object-in-c
11th Feb 2023, 10:30 AM
Scott D
Scott D - avatar
+ 3
Just replace NULL with 0.
11th Feb 2023, 10:22 AM
Scott D
Scott D - avatar
+ 2
Create (by calling default constructor) and return TVAL. Line 56 return TVAL();
11th Feb 2023, 10:58 AM
Ipang
+ 2
Ipang if value has 0, then it will give the value that has been stored with a certain key (but there is no the valid value for the key) On line 77 (in my code) value 0 has been set for "index 3"
11th Feb 2023, 11:09 AM
Gibran Daffa
Gibran Daffa - avatar
+ 2
Ipang sorry my english is bad, Like this: myMap->set("index 3", 0); // will give you 0 value that same as with "index 3" value if the return value is TVAL(); myMap->get("index 4"); I want the value will give like null or something else
11th Feb 2023, 3:50 PM
Gibran Daffa
Gibran Daffa - avatar
+ 2
Oh it's okay, now I clearly understood that's what matters ... Well, Mirielle & Scott had given you good advice. Both are applicable the choice is yours :D
11th Feb 2023, 3:56 PM
Ipang
0
Scott D if the TVAL is not int, the return 0 will be error
11th Feb 2023, 10:28 AM
Gibran Daffa
Gibran Daffa - avatar
0
What did you mean Gibran Daffa ?
11th Feb 2023, 3:30 PM
Ipang
0
In line 56 rather than returning a non-pointer type, which is Null you shall to return the boolean value false or the number 0(zero) to fix you problem simply and to protect you the compiler from failure.
13th Feb 2023, 7:39 AM
Demissew Getachew
Demissew Getachew - avatar