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
11 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
+ 3
Just replace NULL with 0.
+ 2
Create (by calling default constructor) and return TVAL.
Line 56
return TVAL();
+ 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"
+ 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
+ 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
0
Scott D if the TVAL is not int, the return 0 will be error
0
What did you mean Gibran Daffa ?
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.