# Include <iostream. h> // The code is very simple. You only need to use this header file in VC 6.0. Otherwise, it cannot be compiled.
// # Include <iostream>
// Using namespace std;
Class IP
{
Public:
IP (int I = 0, int j = 0, int k = 0, int m = 0)
{
I =;
J = B;
K = c;
M = d;
}
Friend istream & operator> (istream & input, IP & h );
Friend ostream & operator <(ostream & output, IP & h );
Void print ()
{
Printt ();
Cout <".";
Printt (B );
Cout <".";
Printt (c );
Cout <".";
Printt (d );
Cout <'/N ';
}
Void printt (int)
{
Int B = 128;
For (int I = 1; I <= 8; I ++) // convert it to an eight-bit binary number.
{
Cout <a/B;
A = a % B;
B = B/2;
}
}
Private:
Int;
Int B;
Int c;
Int d;
};
Istream & operator> (istream & input, IP & h)
{
Input> h.a;
Input. ignore (); // read "."
Input> h. B;
Input. ignore (); // read "."
Input> h.c;
Input. ignore (); // read "."
Input> h. d;
Return input;
}
Ostream & operator <(ostream & output, IP & h)
{
H. print (); // call the print () function. You can also directly call the member output in the class.
Return output;
}
Int main ()
{
IP address;
Cin> ip address;
Cout <ip;
Return 0;
}
Running result: