c/c++:c++ pseudo function

Source: Internet
Author: User


C + + pseudo function:

The so-called pseudo-function means that it is not a real function, but a class or a struct.


<span style= "FONT-SIZE:18PX;" > #include <iostream>void say_hello () {    std::cout << "Hello world!" << Std::endl;} Class Hello{public:    void Operator () () {         std::cout << "Hello cpp!" << Std::endl;    } overloaded operator ();}; int main () {    Say_hello ();    Hello p;    P ();    return 0;} </span>


Like the Say_hello () call in code is the function call we normally use, and we use the p defined by Hello,

and then P (), which is what we call pseudo-functions. What are the benefits or advantages of pseudo-functions?

Its advantage is that it can be passed. As defined by Hello, it is like a variable,

Convenient, and can also be called by other classes. This is not the normal function that we normally write.







c/c++:c++ pseudo function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.