• Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk

MyCodeTips mycodetips-newlogocopy1

  • Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
IOSQuestions

What is the difference between Objective-C from C++

What is the difference between Objective-C from C++

 

Also Read : What is Reference Count in Objective-C’s Memory Management.

Also Read : What is Delegate Means in Objective-C (IOS Application Development)

 

C++

  • Allows multiple inheritance
  • A C++ member function signature contains the function name as well as just the types of the parameters/return (without their names).
  • C++ uses bool, true and false,
  • C++ uses void* and NULL,
  • It will crash if you try to call a member function of NULL
  • C++ where the object a method is invoked upon must be known at compile time
  • Contrast to C++, where if you create a new instance of a class (either implicitly on the stack, or explicitly through new) it is guaranteed to be of the type you originally specified.
  • C++ allow implicit method overloading, That is, in C++ int foo (void) and int foo (int) define an implicit overload of the method foo.
  • where in C++ they are treated as almost exactly the same

 


Objective-C

  • It doesn’t allows multiple inheritance
  • Allows method parameters to be named and the method signature includes only the names and types of the parameters and return type .
  • Uses BOOL, YES and NO.
  • Prefers id and nil.
  • Uses “selectors” (which have type SEL) as an approximate equivalent to function pointers.
  • Uses a messaging paradigm (a la Smalltalk) where you can send “messages” to objects through methods/selectors.
  • It will happily let you send a message to nil,
  • Allows for dynamic dispatch, allowing the class responding to a message to be determined at runtime
  • Allows autogeneration of accessors for member variables using “properties”.
  • Allows assigning to self, and allows class initialisers (similar to constructors) to return a completely different class if desired.
  • Other classes may also dynamically alter a target class at runtime to intercept method calls.
  • Lacks the namespace feature of C++.
  • Lacks an equivalent to C++ references.
  • Lacks templates, preferring (for example) to instead allow weak typing in containers.
  • Doesn’t allow implicit method overloading , in Objective-C requires the explicit overloads – (int) foo and – (int) foo:(int) intParam. This is due to Objective-C’s named parameters being functionally equivalent to C++’s name mangling.
  • It will happily allow a method and a variable to share the same name
  • It doesn’t allow objects to be created on the stack – all objects must be allocated from the heap (either explicitly with an alloc message, or implicitly in an appropriate factory method).
  • Like C++, Objective-C has both structs and classes.
  • in Objective-C they are treated wildly differently – you can create structs on the stack, for instance.

 

Liked it? Take a second to support Ranjan on Patreon!
become a patron button
  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 1311 Views
AUTHOR
Ranjan

Namaste, My name is Ranjan, I am a graduate from NIT Rourkela. This website is basically about of what i learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures, its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

Next Post
Previous Post

Support us

mycodetips
mycodetips

Follow us @ LinkedIn 2850+

Subscribe for updates

Join 8,213 other subscribers

Latest Posts

  • YT-Featured-solidprinciples
    SOLID Principles of Software Design
  • IOS 16 Features
    Latest features in IOS 16
  • r-language
    How can R language be used for data analysis?
  • wordpress-coding-blog
    Guide To WordPress Coding Standards
  • YT-Featured-Algorithm
    What is Algorithm?
  • Frameworks of IOS
    Frameworks of IOS – Part ( I )
  • NSFileManager or NSPathUtilities
    NSFileManager or NSPathUtilities in Objective-C
  • Passing data between view controllers in Objective-C
    Passing data between view controllers in Objective-C
  • structures-classes-enum
    Structures and Classes in swift !
  • control-system-swift
    Control Flow in Swift
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Android Studio API APP Programming Apps blogging CSS DATABASE dsa Features HTML HTML5 installation Interview Questions IOS iPhone javascript Mac objective-c OS Programming quicktips SDK SEO SQL swift Tips & Tricks Tools UI Web Wordpress Xcode

  • SOLID Principles of Software Design
  • Latest features in IOS 16
  • How can R language be used for data analysis?
  • Guide To WordPress Coding Standards
  • What is Algorithm?

©mycodetips.com