我
我是张小三
Unregistered / Unconfirmed
GUEST, unregistred user!
/*初学C++,还请各位大侠多多指教!*/
/*用VC++6.0调试控制台程序时遇到如下问题,请指教。谢谢!*/
#include <iostream.h>
typedef unsigned short USHORT;
enum ERR_CODE{SUCCESS, ERROR};
ERR_CODE Factor(USHORT, USHORT &, USHORT &
void main()
{
USHORT number, squared, cubed;
ERR_CODE result;
cout << "Enter a number(0-20):";
cin >> number;
result = Factor(number, squared, cubed);
if (result == SUCCESS)
{
cout << "number:" << number << "/n";
cout << "square:" << squared << "/n";
cout << "cube:" << cubed << "/n";
} //为什么这里不能有分号?
else
cout << "Error encountered! /n";
cout << endl;
}; //为什么这里可以有也可以没有分号?
ERR_CODE Factor(USHORT n, USHORT &rSquared, USHORT &rCubed)
{
if (n > 20)
return ERROR; //为什么这里必须有分号?
else
{
rSquared = n * n;
rCubed = n * n * n;
return SUCCESS;
};
};
/*用VC++6.0调试控制台程序时遇到如下问题,请指教。谢谢!*/
#include <iostream.h>
typedef unsigned short USHORT;
enum ERR_CODE{SUCCESS, ERROR};
ERR_CODE Factor(USHORT, USHORT &, USHORT &
void main()
{
USHORT number, squared, cubed;
ERR_CODE result;
cout << "Enter a number(0-20):";
cin >> number;
result = Factor(number, squared, cubed);
if (result == SUCCESS)
{
cout << "number:" << number << "/n";
cout << "square:" << squared << "/n";
cout << "cube:" << cubed << "/n";
} //为什么这里不能有分号?
else
cout << "Error encountered! /n";
cout << endl;
}; //为什么这里可以有也可以没有分号?
ERR_CODE Factor(USHORT n, USHORT &rSquared, USHORT &rCubed)
{
if (n > 20)
return ERROR; //为什么这里必须有分号?
else
{
rSquared = n * n;
rCubed = n * n * n;
return SUCCESS;
};
};