при работе в try-catch in наткнулся на эту ошибку.Но я не могу отследить причину этой ошибки, хотя я просматривал Интернет и SO .
Мой код ...
int main()
{
Queue q;
int choice,data;
while(1)
{
choice = getUserOption();
switch(choice)
{
case 1:
cout<<"\nEnter an element:";
cin>>data;
q.enqueue(data);
break;
case 2:
int element;
element = q.dequeue();
cout<<"Element Dequeued:\n"<<element;
break;
case 3:
q.view();
break;
case 4:
exit(EXIT_SUCCESS);
}
catch(UnderFlowException e)
{
cout<<e.display();
}
catch(OverFlowException e)
{
cout<<e.display();
}
}// end of while(1)
return 0;
}
Для меня все вприведенный выше код представляется правильным.Но компилятор g ++ выбрасывает ...
muthu@muthu-G31M-ES2L:~/LangFiles/cppfiles/2ndYearLabException$ g++ ExceptionHandlingEdited.cpp
ExceptionHandlingEdited.cpp: In member function ‘void Queue::enqueue(int)’:
ExceptionHandlingEdited.cpp:89:97: warning: deprecated conversion from string constant to ‘char*’
ExceptionHandlingEdited.cpp: In member function ‘int Queue::dequeue()’:
ExceptionHandlingEdited.cpp:113:95: warning: deprecated conversion from string constant to ‘char*’
ExceptionHandlingEdited.cpp: In member function ‘void Queue::view()’:
ExceptionHandlingEdited.cpp:140:66: warning: deprecated conversion from string constant to ‘char*’
ExceptionHandlingEdited.cpp: In function ‘int main()’:
ExceptionHandlingEdited.cpp:185:3: error: expected primary-expression before ‘catch’
ExceptionHandlingEdited.cpp:185:3: error: expected ‘;’ before ‘catch’
ExceptionHandlingEdited.cpp:189:3: error: expected primary-expression before ‘catch’
ExceptionHandlingEdited.cpp:189:3: error: expected ‘;’ before ‘catch’