We've been doing a variety of exercises from the start using C + + input and output, the input output is provided by the iostream library, so it is necessary to discuss this standard library, unlike the Stdio Library of C, which from the outset is an object-oriented hierarchy implemented with multiple inheritance and virtual inheritance. As a standard library component for C + + to be used by programmers.
Iostream provides input and output support for built-in type-type objects, as well as file input and output, and the designer of the class can support the custom type of input-output operations by extending the iostream library.
Why do you want to expand to provide support? Let's take an example.
#include <stdio.h>
#include <iostream>
using namespace Std;
Class Test
{
Public
Test (int a=0,int b=0)
{
Test::a=a;
Test::b=b;
}
int A;
int b;
};
int main ()
{
Test T (100,50);
printf ("%???", t);//Ambiguous output format
scanf ("%???", t);//Ambiguous input format
Cout<<t<<endl;//is also not clear enough
Cin>>t;//is also not clear enough
System ("pause");
}
Because of the specificity of the custom class, in the above code, whether you use C-style input output, or C + + input and output is not an ambiguous representation, because the C language does not have operator overloading mechanism, resulting in the Stdio library is not scalable, so we can not let printf () and scanf () Supports extended recognition of custom class objects, and C + + is the ability to extend iostream libraries through operator overloading mechanisms, allowing the system to recognize custom types so that input and output know exactly what they should do and what format to use.