Re: As a programmer of both languages...



jacob navia wrote:

struct A {
int age;
char *Name;
};

int main(void)
{
A jacob;
}

This is valid C++ but invalid C. In C++ each "structure" definition
is just a CLASS where all members are PUBLIC by default. I see this
explanation in all C++ books I read but in my ignorance I believe
them. Stupid isn't it?

I think I see your conceptual problem, do you claim that

class A {
public:
int age;
char *Name;
};

Is OO while

struct A {
int age;
char *Name;
};

isn't?

You appear to be confusing the use of structures with object orientation.

One can choose to write OO code in C or in C++. The choice depends of
the nature of the problem. One of the cleanest OO designs I have seen
is the old OpenView GUI toolkit, a textbook example of OO C.

--
Ian Collins.
.



Relevant Pages