首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

打的第一个C++程序。编译不通过解决方法

2012-03-16 
打的第一个C++程序。编译不通过[codeC/C++][/code#includeiostreamusing namespace stdclass Box{priva

打的第一个C++程序。编译不通过
[code=C/C++][/code#include<iostream>
using namespace std;

class Box
{
private:
int length,width,height,volume;
void vprint();
public:
void volume(int nlength,int nwidth,int nheight);
};

void Box::volume(int nlength,int nwidth,int nheight)
{
length=nlength;
width=nwidth;
height=nheight;
}

void Box::vprint()
{
volume=length*width*height;
cout<<volume<<endl;
}

void main()
{
Box a;
int l,w,h;
cout<<"请输入长宽高:"<<endl;
cin>>l>>w>>h;
a.volume(l,w,h);
a.vprint();
}]


[解决办法]
volume变量名于函数名重复。
[解决办法]

C/C++ code
//2个问题私有成员和函数名重名(volume),a.vprint();私有不可调用
[解决办法]
输入是多少?输出是多少?

热点排行