C
1 2 3 4 5 6 7 | #include <stdio.h> int main(void) { printf("Hello, world!\n"); return 0; } |
C++
1 2 3 4 5 6 | #include <iostream> using namespace std; int main () { cout << "Hello, world!\n"; } |
Objective C
Procedural C Version
1 2 3 4 5 6 7 | #import <stdio.h> int main (int argc, const char *argv[]) { printf ("Hello, world!\n"); return 0; } |
Object-Oriented C Version
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #import <stdio.h> #import <objc/Object.h> @interface Hello : Object { } - hello; @end @implementation Hello - hello { printf("Hello, world!\n"); } @end int main(void) { id obj; obj = [Hello new]; [obj hello]; [obj free]; return 0; } |