Object-c: an object-oriented understanding

Source: Internet
Author: User

Object-c: an object-oriented understanding

After learning C language, I know that the difference between the two languages is a little big. C language is a process-oriented language, and O-C is an object-oriented language, for example (of course it is old), just like a sketch of Zhao Benshan and Song Dandan during the Spring Festival, it is said to put the elephant in the refrigerator in a few steps. I guess you already know the answer, there are three steps.

Step 1: open the refrigerator door

Step 2: Put the elephant in

Step 3: Close the refrigerator door

If we use C language for implementation, we need to write three functions to implement three functions. First, we need to create a function to open the refrigerator door. Second, we need to create a function, the third step is to create a function to close the refrigerator door.

However, the object-oriented language actually operates on objects. Unlike the C language, we only need to know who the object is. Who are we going to operate on in this question? The answer is of course the refrigerator. Now we have changed from the original executor to the conductor. We only need to tell the refrigerator the operation we want to perform, as for how to implement it, we don't care about it (or you want to care that Apple's source code is closed, and you don't see it either. You just need to know which functions are called to implement which functions)

Here, we only need to execute the function functions of the three refrigerators.

1. First create a refrigerator object

2. open the refrigerator (just tell him to open it)

3. Refrigerator. Put the elephant in (just tell him we want to store it)

4. Close the refrigerator (just tell him we want to use this function to close the door)

Here, we will not care about how to open it, how to put the elephant in, and how to close the door.

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.