Description
补足程序,使得下面程序输出的结果是:
****100
#include <iostream>
#include <string>
using namespace std;
// Your Code Here
string Print1()
{
return "****";
}
int Print2()
{
return 100;
}
int main()
{
cout << Print1 << Print2 << endl;
return 0;
}
Output
****100
解法如下:
#include <iostream>
#include <string>
using namespace std;
ostream& operator<<(ostream& out, string (*p)())
{
out << (*p)();
return out;
}
ostream& operator<<(ostream& out, int (*p)())
{
out << (*p)();
return out;
}
string Print1()
{
return "****";
}
int Print2()
{
return 100;
}
int main()
{
cout << Print1 << Print2 << endl;
return 0;
}