How is Objective C different from C++?


Posted On: Feb 22, 2018


There are a considerable amount of difference between c and c++ :

Objective CC++
The classes in Objective C allow a method or function and a variable with the exact same name.In case of C++, they must be different.
Objective C does not support a constructor or destructor. Instead, it has init and dealloc methods, which must be called explicitly when needed.C++ supports constructors and destructors.
Objective C uses the signs + and – to differentiate between class methods (which are also known as factory methods in Java) and instance methods.On the other hand, C++ uses static to specify a factory method.
Multiple inheritances is not allowed in Objective C, however, a user can use a protocol to some extent.Multiple inheritances are allowed in C++.
Objective C does not directly allow for method overloading and has a workaround, but that is not the case for operator overloading.C++ directly allows for method overloading.
Objective C does not allow stack-based objects either. Each object must be a pointer to a block of memory for it to exist.C++ can use stack based objects which is automatically allocated, instantiated and deallocated on the stack.
In Objective C the message overloading is somehow faked by naming the parameters. The user is required to mangle the names manually.C++ actually does the same but the compiler does the name mangling for the user instead of having to do it himself.
Objective C doesn’t allow automatic type coercion.C++ allows automatic type coercion.
Objective C has references. But as pointers can be used wherever a reference is employed, there isn’t any specific need for references in general.C++ has references as the language requires.
Objective C doesn’t have templates.The users of C++ need templates because the programming language has a strong typing and static binding that prevents generic classes, such as Lists and Arrays.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    C++ Interview Questions

    Explain what is OOP?

    Object-oriented programming (OOP) is a type of computer programming, also more commonly known as software design, in wh..

    C++ Interview Questions

    What is the difference between #import and #include in C++?

    The statement #include is used in C++ to include the source file or import the header files containing definitions of f..

    C++ Interview Questions

    What is ‘this’ pointer?

    The ‘this’ pointer is passed as a hidden argument to all the non-static member method calls and is available as a l..