17.CPP-Module-05

  • Nested classes = classes imbriquées
  • Exceptions

Nested classes

class cat
{
  class paw
}
cat::paw instance;

Exceptions :

class GradeTooHighException : public std::exception				
{
	public:
				virtual const char *what() const throw()
        {
            return ("Bureaucrat::exception : Grade is too high");
	}
};

try
{
 	 if (grade > max)
          	throw GradeTooHighException() ;
}
catch (std::exception &e)
{
   	  cout << e.what() << endl;
}