简体   繁体   English

返回后 Cout 不起作用

[英]Cout doesn't work after return

Cout (and everything else I've attempted to put after the return) doesn't work when placed after the return in this function. Cout(以及我尝试在返回之后放置的所有其他内容)在此函数中的返回之后放置时不起作用。 What's wrong?怎么了?

   float tanDegrees() {
    string i;
    double iDouble;
    string choice;

    cout << "Give me a number to find the value of degrees in. ";
    getline(cin, i);

    iDouble = stod(i);

    double PI = 3.14159265359;

    float answer = tan((PI / 180)*iDouble);

    cout << "Test!" << endl;

    return answer;

    cout << "Test!" << endl;

}

The return causes you to leave the function's scope.返回使您离开函数的作用域。 So anything after "return" won't be touched.所以“返回”之后的任何东西都不会被触及。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM