Objective C Vs C++
2045
10-Sep-2015
Updated on 23-Sep-2020
Tarun Kumar
10-Sep-2015- The Objective C class allows a method and a variable with the exact same name. In C++, they must be different.
- Objective C does not have a constructor or destructor, instead it has init and dealloc methods, which must be called explicitly.
- Objective C uses + and – to differentiate between factory and instance methods, C++ uses static to specify a factory method.
- Multiple inheritance is not allowed in Obj C, however we can use protocol to some extent.
- Obj C has runtime binding leading to dynamic linking.
- Obj C has got categories.
- Objective C has a work-around for method overloading, but none for operator overloading.
- Objective C also does not allow stack based objects. Each object must be a pointer to a block of memory.
- In Objective C the message overloading is faked by naming the parameters. C++ actually does the same thing but the compiler does the name mangling for us. In Objective C, we have to mangle the names manually.
- One of C++’s advantages and disadvantages is automatic type coercion.
- Another feature C++ has that is missing in Objective C is references. Because pointers can be used wherever a reference is used, there isn’t much need for references in general.
- Templates are another feature that C++ has that Objective C doesn’t. Templates are needed because C++ has strong typing and static binding that prevent generic classes, such as List and Array.