Permalink
Cannot retrieve contributors at this time
| description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid |
|---|---|---|---|---|---|
|
Learn more about: Compiler Warning (level 1) C4716 |
Compiler Warning (level 1) C4716 |
11/04/2016 |
C4716 |
C4716 |
d95ecfe5-870f-461f-a746-7913af98414b |
‘function’ must return a value
The given function did not return a value.
Only functions with a return type of void can use the return command without an accompanying return value.
An undefined value will be returned when this function is called.
This warning is automatically promoted to an error. If you wish to modify this behavior, use #pragma warning.
The following sample generates C4716:
// C4716.cpp // compile with: /c /W1 // C4716 expected #pragma warning(default:4716) int test() { // uncomment the following line to resolve // return 0; }
ostream &operator<<(ostream &os, const PT &p) {
os << "(" << p.x << "," << p.y << ")";
}
как исправить код?
задан 14 ноя 2017 в 12:31
1
1 ответ
ostream& operator<<(ostream& os, const PT& p)
{
os << "(" << p.x << "," << p.y << ")";
return os;
}
ответ дан 14 ноя 2017 в 13:26
JensJens
3,3652 золотых знака18 серебряных знаков43 бронзовых знака
- Forum
- Beginners
- C4716 Error: Must return a value
C4716 Error: Must return a value
I am an absolute noob to programming and i’m having some serious problems. This is a problem i have for my programming class and I’m stumped. It’s saying a have to return a value to the main from a function but i just don’t understand why or why it’s won’t compile. PLEASE help! 🙁
|
|
It saying «error C4716: ‘displayData’ : must return a value» when i try to compile it. What am i doing wrong??
Any help, or tips is greatly appreciated. Thank you!
Either declare the displayData Function as void like:
|
|
or return a double.
|
|
Last edited on
Ok, tried both and neither compiled. I changed the function to void and the prototype to void
|
|
|
|
and i changed it to return a double as well.
|
|
and the error for both of them was:
» 1>main.obj : error LNK2019: unresolved external symbol «double __cdecl getWidth(void)» (?getWidth@@YANXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol «double __cdecl getLength(void)» (?getLength@@YANXZ) referenced in function _main
fatal error LNK1120: 2 unresolved externals»
I am clueless. I can’t figure out whats wrong.
Last edited on
Well, the functions called on main is getWidth() and getLength(). However, you’ve only defined the functions getLength(double) and getWidth(double). Remove those doubles and it should be fine.
Last edited on
Topic archived. No new replies allowed.