#include <iostream>

// An IPv4 address has the following form:
// "A.B.C.D", where A, B, C and D are bytes
class IPAddress {
 public:
     IPAddress (unsigned char a = 0, unsigned char b = 0, unsigned char c = 0, unsigned char d = 0);

     IPAddress operator& (const IPAddress& addr) const;
     IPAddress operator| (const IPAddress& addr) const;
     IPAddress operator~ () const;
     
     bool operator== (const IPAddress& addr) const;
     bool operator!= (const IPAddress& addr) const;

     friend std::ostream& operator<< (std::ostream& os, const IPAddress& addr);
     friend std::istream& operator>> (std::istream& is, IPAddress& addr);

     void setAddress (unsigned char a, unsigned char b, unsigned char c, unsigned char d);

 private:
     unsigned char m_a;
     unsigned char m_b;
     unsigned char m_c;
     unsigned char m_d;
};
#ifndef _IP_ADDRESS_H_
#define _IP_ADDRESS_H_

#include <iostream>

// An IPv4 address has the following form:
// "A.B.C.D", where A, B, C and D are bytes
class IPAddress {
 public:
     IPAddress (unsigned char a = 0, unsigned char b = 0, unsigned char c = 0, unsigned char d = 0);

     IPAddress operator& (const IPAddress& addr) const;
     IPAddress operator| (const IPAddress& addr) const;
     IPAddress operator~ () const;
     
     bool operator== (const IPAddress& addr) const;
     bool operator!= (const IPAddress& addr) const;

     friend std::ostream& operator<< (std::ostream& os, const IPAddress& addr);
     friend std::istream& operator>> (std::istream& is, IPAddress& addr);

     void setAddress (unsigned char a, unsigned char b, unsigned char c, unsigned char d);

 private:
     unsigned char m_a;
     unsigned char m_b;
     unsigned char m_c;
     unsigned char m_d;
};

#endif // _IPADDRESS_H_
Add header guard to prevent multiple inclusion errors
Add header guard to prevent multiple inclusion errors
