我有这样的语句,旨在输出函数返回的内容。
std::cout<<"result: " << calculateAvg(someArray, size) << std::endl;
然而,该函数在返回值之前会自行输出内容。有没有办法让我打印出该行返回的内容,而不是在函数打印的所有内容之后?
最佳答案
Is there a way for me to print out what is returned on that line, instead of after everything that is printed by the function?
没有。该函数必须先运行才能返回某些内容。这意味着函数输出的任何输出都将出现在函数返回值的输出之前。
关于C++ 输出顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34886909/