Simple2012

Untitled

Jan 30th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. void test(){
  2.     try{
  3.         if (empty())
  4.             throw empty_list();
  5.             std::cout << p_que.front().owner << p_que.front().price << std::endl;
  6.         }
  7.     catch (std::exception &e){
  8.         std::cout << "List is empty. " << std::endl << "Error message: " << e.what() << std::endl << std::endl;
  9.     }
  10. }
  11.  
  12.  
  13. #pragma once
  14. #include <exception>
  15. #include <iostream>
  16.  
  17.  
  18. class empty_list:public std::exception
  19. {
  20. public:
  21.     const char* what() const throw(){
  22.         return "You cannot print the list because there's nothing in it.";
  23.     }
  24. };
Advertisement
Add Comment
Please, Sign In to add comment