c/c++:c++ pseudo function

Source: Internet
Author: User


C + + pseudo function:

The so-called pseudo function. This means that it is not a real function, but rather 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>


Calls like Say_hello () in code are the function calls we use frequently. And we use Hello to define the p.

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

its strength lies in its ability to pass on. As defined by Hello, it is like a variable. Convenient.

It can also be called by other classes and members. Ordinary functions that we normally write can only rely on global variables.







c/c++:c++ pseudo function

Related Article

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.