看板Programming
标 题希望C++传送「长度错误」等文字回去
发信站KKCITY (Sun Sep 16 17:23:15 2007)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.nsysu!news.isu!Leo.mi.chu!zoone
请问一下,我在class内侦测传送过来的资料当东西产生时,传送错误的代码回去,
如果我希望他传送的是「长度错误」等文字回去,那我该怎麽写呢?
谢谢!
附上原始语法如下:
#include <iostream>
class CBox
{
private:
double length;
double breadth;
double height;
public :
double Volume(double a,double b,double c)
{ if (a<0)
return -1;
else if (b<0)
return -2;
else if (c<0)
return -3;
else { length=a;
breadth=b;
height=c;
return height*length*breadth; } }
};
using namespace std;
int main()
{
CBox box1;
CBox box2;
double boxVolume = 0.0;
cout << endl
<< "Volume of box1 =" << box1.Volume(10,50,60);
cout << endl
<< "Volume of box2 ="
<< box2.Volume(10,-10,20); //虽然资料有错 但是东西仍产生了 只是这是不良品
cout <<endl;
system("PAUSE");
return 0;
}
--
┌─────◆KKCITY◆─────┐ ◢
◤ 找歌最方便 KKBOX 歌词搜寻!!
│ bbs.kkcity.com.tw │ \^_^ / ★http://www.kkbox.com.tw★
└──《From:14.19.19.16
》──┘ ◤ 唱片公司授权,音乐尽情下载
--
1F:→ sunneo:...220.132.228.138 09/17 00:20