# Include <iostream>
# Include <string>
Using namespace STD;
Class display
{
Public:
Void operator () (string strin) const
{
Cout <strin <Endl;
}
};
Int main ()
{
Display display;
Display. Operator () ("display ");
Display ("display ");
Int Z; // This is to hold the screen and prevent it from disappearing.
Cin> Z;
Return 0;
}
Operator Function
The reason for using display as a function is that the compiler implicitly calls the operator () function.
Because this operator also becomes the operator () function, the object dispaly becomes the function object.
Author: Lin yufei
Source: http://www.cnblogs.com/zhengyuhong/
The copyright of this article is shared by the author and the blog Park. You are welcome to repost it. However, you must keep the author's information without the author's consent and provide the original article connection clearly on the article page.