C and OC Comparisons

Source: Internet
Author: User
Tags finally block function definition

1) source File comparison

Think & Implement 1:1) in the C language, what are the files that we encounter with different suffixes?

. C. O. h

  

2. Basic grammatical comparison

1) Data type comparison learning

      

2) definition Comparison of variables

  

3) Comparison of flow control statements

1) if else 2) switch 3) while 4) do and 5) for

Added: Enhanced for loop for fast traversal of arrays, dictionaries, and other collections

  

4) function (method) definition and declaration comparison

Declaration and implementation of functions in C language

I. Function declaration:

int sum (int a,int b);

II. function definition
int sum (int a,int b) {

return a+b;

}

The function habit in OC language is called "method"

I. Method declaration:
-(int) sum: (int) A and: (int) b;

II. METHOD definitions
-(int) sum: (int) A and: (int) b{

return a+b;

}

5) OC New data type

A Boolean type is a variable used to store true and false values, and is typically used for program flow control.

The Boolean data allows for a value of true or FALSE, or an integer of 0 or not 0 to replace true and false, which differs from the Java language.

6) New Exception Capture method in OC @try ... @catch ... @finally

Format:

    

The code may throw a possible exception that is enclosed at an @ try block. The @catch () block contains exception handling logic for exceptions thrown for the @ try block. An @ finally block contains code that must be executed to throw an exception or not. You can use the @throw directive to throw an exception, which is basically a pointer to the Objective–c object. You can use the NSException object

The instruction throws an exception, which is basically a pointer to the Objective–c object. You can use NSException objects but not them.

    

C and OC Comparisons

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.