注册 登录
编程论坛 C++教室

默认实参运行结果有乱码,怎么回事??

魔鬼鱼 发布于 2011-03-25 21:04, 500 次点击

#include<iostream.h>
int main(int argc, char* argv[])
{int boxvolume(int length=1,int width=1,int hight=1);

    cout<<"The default box volume is"<<boxvolume();
    cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 1 and height 1 is: "<<boxvolume(10);
    cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 5 and height 1 is: "<<    cout<<boxvolume(10,5);
cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 5 and height 2 is: "<<    cout<<boxvolume(10,5,2)<<endl;
}

int boxvolume(int length,int width,int hight)
{
    return length*width*hight;
}

6 回复
#2
玩出来的代码2011-03-26 12:13
cout<<cout(10,1)<<endl;
你认为应该输出什么?
#3
玩出来的代码2011-03-26 12:14

是这个,cout<<cout<<boxvolume(10,1)<<endl;
#4
loveshuang2011-03-26 19:27
#include<iostream.h>
int main(int argc, char* argv[])
{int boxvolume(int length=1,int width=1,int hight=1);

    cout<<"The default box volume is"<<boxvolume();
    cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 1 and height 1 is: "<<boxvolume(10);
    cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 5 and height 1 is: "<<boxvolume(10,5);
cout<<"\n\nThe volume of a box with length 10,\n"
        <<"width 5 and height 2 is: "<<boxvolume(10,5,2)<<endl;
}

int boxvolume(int length,int width,int hight)
{
    return length*width*hight;
}

#5
魔鬼鱼2011-03-26 19:43
回复 2楼 玩出来的代码
我懂了。。
谢谢各位

[ 本帖最后由 魔鬼鱼 于 2011-3-26 19:50 编辑 ]
#6
pangding2011-03-26 20:20
原来是这种错误……
我昨天看了一阵也没看出来是为什么。
#7
linzhiqing2011-03-29 09:55
哇艹,看完才知道这个问题怎么怎么傻。。。呵呵呵
1