在线等关于异常处理C+小问题
#include<iostream>
using namespace std;
void main(int argc,char*argv[])
{
try
{
int a,b;
cout<<"please input a num:";
cin>>a>>endl;
cout<<"please input again:";
cin>>b>>endl;
if(b==0) throw b;
cout<<"a/b="<<a/b<<endl;
}
catch(int)
{
cout<<"除数为0"<<endl;
}
}
错误:error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
么子意思 怎么修改啊?
[解决办法]
cin>>a>>endl;去掉endl cin>>a; cin是输入流,不需要endl。
[解决办法]