如何打印返回值的结果?我是初学C++的初学者

如何打印返回值的结果?我是初学C++的初学者,c++,C++,我在哪里添加cout这应该有效: int sumTo(int value) { int total(0); for (int count=1; count <= value; ++count) total += count; return total; } 问题出在哪里还不清楚。你知道如何调用函数吗?展示你的尝试。听起来你可以从中受益。C++是无法通过猜测来学习的。这个版本更好吗?很好用!谢谢你的帮助! #include <iostream> int sumTo(

我在哪里添加cout这应该有效:

int sumTo(int value)
{
int total(0);
for (int count=1; count <= value; ++count)
    total += count;

return total;
}

问题出在哪里还不清楚。你知道如何调用函数吗?展示你的尝试。听起来你可以从中受益。C++是无法通过猜测来学习的。这个版本更好吗?很好用!谢谢你的帮助!
#include <iostream>

int sumTo(int value)
{
    int total = 0;
    for (int count=1; count <= value; ++count)
        total += count;

    return total;
}

int main(void)
{
    std::cout << sumTo(12);
}