标题:哪里错误了?我照书打的
取消只看楼主
chen1204019
Rank: 1
来 自:广东
等 级:新手上路
帖 子:93
专家分:0
注 册:2012-12-3
结帖率:90.63%
已结贴  问题点数:20 回复次数:0 
哪里错误了?我照书打的
//带默认 参数的函数举例
#include <iostream>
#include <iomanip>
using namespace std;

int getVolume(int length, int width=2, int height=3);

int main()
{
    const int X=10, Y=12, Z=15;
    cout<<"Some box data is";
    cout<<getVolume(X, Y, Z)<<endl;
    cout<<"Some box data is";
    cout<<getVolume(X, Y)<<endl;
    cout<<"Some box data is";
    cout<<getVolume(X)<<endl;
    return 0;
}

int getVolume(int length, int width/*=2*/, int height/*=3*/)
{
    cout<<setw(5)<<length<<setw((5)<<width<<setw(5)<<height<<'\t';
    return length * width * height;
}
搜索更多相关主题的帖子: include return 
2013-03-12 23:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-400616-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091924 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved