The usage of Block variables makes your program clear and clear !, Block Variable

Source: Internet
Author: User

The usage of Block variables makes your program clear and clear !, Block Variable

  1. <Span style = "font-size: 24px;"> Why use block variables?
  2. Because when our programs are complicated, we need to call a function in a function and define it outside, which is inconvenient to implement, however, with block variables, we can define a block variable within a function, which is equivalent to defining a function within the function.
  3. Int (^ max) (int x, int y) = ^ (int x, int y) // calculates the maximum value of two numbers.
  4. {
  5. Return x> y? X: y;
  6. };
  7. NSLog (@ "% d", max (5, 10 ));
  8. Int (^ min) (int x, int y) = ^ (int x, int y) // calculates the minimum value of two numbers.
  9. {
  10. Return x> y? Y: x;
  11. };
  12. NSLog (@ "% d", min (5, 10); </span>
[Cpp]View plaincopy
  1. <Pre name = "code" class = "cpp"> <span style = "font-size: 24px;"> The block Variable type is int (^) (int x, int y );
  2. Max is the variable name. It generally depends on the function type. You only need to remove the function name and the rest is the function type.
  3. ^ (Int x, int y)
  4. {
  5. Return x + y;
  6. }
  7. The block variable is initialized above. </span>

[Cpp]View plaincopy
  1. <Span style = "font-size: 24px;"> If a local variable defined externally by the block is used inside the block, if the variable is not modified by _ block, the block is read-only and cannot be modified. to modify the block, _ block must be added before the variable.
  2. _ Block tells the compiler not to use external variables as constants or variables in the block during compilation.
  3. If you access global variables in the block, you do not need to modify the _ block,

The error message "91 object variables not set or with block variables" is displayed when the chemical gold medal is running. The word version I use is WPS.

It is best to apply the chemical gold to word2003, which is not suitable for wps currently.

Program running error written in VB: ActiveX cannot create objects. runtime error: "91" no object variable or with block variable is set

To reference objects, third-party applications that come with the system in components must be registered first.

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.