Menu

Please Write Code C Objectives Familiarize Student Using Exceptions Real Programs Simplifi Q43779764

please write the code in C++  

Objectives

Familiarize the student with:

  • using exceptions in real programs;
  • the simplification of exception throwing;
  • throwing exceptions in constructors.

Scenario

IP header – imagine you have a class or struct (choose one)describing an IP header which holds (apart from other fields) twostring fields that contain Source IP Address and Destination IPAddress. Check these two fields and throw an exception in aconstructor, and using a special check method, try to write oneversion of this code only. The condition of the check method isthat both IP numbers are valid. Start with simple checks – the IPnumber must consist of four numbers in the 0-255 range, separatedby a dot. Append appropriate information about which of the IPnumbers is invalid.

212.112.212.11, 212.112.212.12
212.112.212.333, 212.112.212.33

Valid IP Header.
Invalid IP Header – Source IP Address is invalid.

Expert Answer


Answer to please write the code in C++ Objectives Familiarize the student with: using exceptions in real programs; the simplificat…

OR