0
What type of Error is this C++
I'm learning c++ and have this question at school: What is this kind of error after compailing a program, choose one answer: Return value type does not match the function type The answers offered are: 1. syntax error 2. Error during program execution 3.none of offered answers Anyone know what is the answer????
3 Answers
+ 1
You can test it in SoloLearn playground.
0
Yeah but I dont know enough about c++ to understand what type of error is this can you pls help
0
I have a confusion about what there mean about function type..?
If it about the function arguments type and return type matching then there is no relation for those to be specific types. You can pass or define any type of arguments in function. And you can return a different type of value so no error : option 3.
Ex: int fun(float i, char ch) {
....
...
return 0;
}
If you mean about not match in defined return type and returning value then you may syntax error or warning (with passed value if auto convertion if possible, i.e ex: auto int to double but if need double to string produce error.)
Ex:
int fun() {
..
return 1.9; //warning only
}
Ex: int fun() {
...
return "hello" ; //error. Need int but passing string
}
Finally, question about option 3.. I guess.