C ++ vs objective-C

Source: Internet
Author: User

I accidentally applied for an iPhone development role some time ago. I was asked about the similarities and differences between objc and C ++. I always expressed my preference for C ++. I wrote a bit in two languagesCodeI think I can write some text for a simple comparison.

The first is memory management:

The C ++ version reaches C ++ 11 and does not support language-level GC. It happens that objc has never been willing to support GC on iOS devices.

C ++ is harmonious without GC, because the C ++ object is designed for static memory allocation.

The constructor of C ++ cannot be inherited. It is bound to the object during compilation, but does not have polymorphism at runtime. Therefore, you can know the object size exactly during the compilation period and allocate objects in the stack area.

While objc always binds objects and methods at runtime through the message mechanism. The polymorphism is really good. Through [self class], static methods of classes, such as allloc, are also Runtime polymorphism, therefore, it seems that only objects can be allocated in the heap area.

Alas, I was writing this article to write a better look, earn some clicks, And Then PS job information. The result is half of the phone number, and I finally have a job that suits me, so I am too lazy to write it down. That's all. Sorry.

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.