C , Objetive C, And C++

This is a discussion on C , Objetive C, And C++ within the Tech Board forums, part of the Community Boards category; 1. What is the different between Objective C and Normal C?? ( To my understanding they are just a different ...

Completely different? How about C with OPP. Can you point out a differce(where it will break C instead if bending)?

Driver program in Objective C...I don't know how many times I have to tell you Objective C is not C or C++, it is its own language

Code:

int main (void)
{
/* First create instances of "Stack" and "Queue" data structures. */
id queue = [[Queue alloc] init];
id stack = [[Stack alloc] init];
int i, reply;
fprintf (stderr, "Include the Char class in the demo? (y/n): ");
/* Anything not matching `y.*' means no. */
reply = getchar ();
for (i = 5; i > -6; --i)
{
/* Depending on which version of the demo we're running, we
alternately put Ints and Floats onto the queue and stack, or
Ints, Floats, and Chars. */
if (reply == 'y')
{
/* If I is odd we put an Int on the queue and a Char on the
stack. If I is even we put an Char on the queue and a Float
on the stack.
Since there is more than one method `-init:' and since
`+alloc' returns a plain, typeless, `id', the compiler
doesn't know the type of the object returned by alloc. An
explicit cast (i.e. static type indication) ensures that the
compiler knows which `init:' is invoked---the one accepting a
char or the other one accepting an int.
Another solution, which avoids the static type indication, is
to put typing information on the method in the method's name.
This is done for the Float class. */
id my_char = [(Char *) [Char alloc] init: 'm' + i];
if (i & 1)
{
[queue put: [(Int *) [Int alloc] init: i]];
[stack put: my_char];
}
else
{
[queue put: my_char];
[stack put: [[Float alloc] initFloatValue: i]];
}
}
else
{
/* If I is odd we put an Int on the queue and a Float on the
stack. If I is even we put a Float on the queue and an Int
on the stack. */
[queue put: ((i & 1)
? [(Int *) [Int alloc] init: i]
: [[Float alloc] initFloatValue: i])];
[stack put: ((i & 1)
? [[Float alloc] initFloatValue: i]
: [(Int*) [Int alloc] init: i])];
}
}
while ([queue size] && [stack size])
{
/* The following illustrates run-time binding. Will report be
invoked for a Float object or an Int object? Did the user elect
for Char objects at run time? We don't know ahead of time, but
with run-time binding and polymorphism it works properly. The
burden is on the class implementer rather than the class user.
Note that the following lines remain unchanged, whether we are
using the Char class or not. The queue and stack hand us the
next object, it reports itself regardless of its type, and then
it frees itself. */
printf ("queue:");
[[[queue get] report] free];
printf (", stack:");
[[[stack get] report] free];
putchar('\n');
}
return 0;
}