array of class / code optimization

hg hg at nospam.org
Wed Jan 3 08:25:46 EST 2007


Neil Cerutti wrote:

> On 2007-01-03, Jussi Salmela <tiedon_jano at hotmail.com> wrote:
>> hg kirjoitti:
>>> mm wrote:
>>> 
>>>> Yes, it was the (), equivalent to thiks like new() create new object
>>>> from class xy.
>>>>>   s1.append(Word)
>>>> s1.append(Word())
>>>>
>>>> But I was looking for a "struct" equivalent like in c/c++.
>>>> And/or "union". I can't find it.
>>>>
>>>> Maybe you know a source (URL) "Python for c/c++ programmers" or things
>>>> like that.
>>>>
>>>>
>>>> Yes, I konw whats an object is...
>>> 
>>> 
>>> A struct in C is unrelated to a struct in C++ as a struct in C++ _is_ a
>>> class.
>>> 
>>> 
>>> hg
>>
>> What does your sentence mean, exactly? If I take a C file xyz.c
>> containing a struct definition S, say, rename it to be xyz.cpp
>> and feed it to a C++ compiler, the S sure remains a struct and
>> the C++ compiler has no difficulty in handling it as a struct,
>> so ?!?
> 
> That's true.
> 
> But it's also true that
> 
> struct foo {
>   int x, y;
> };
> 
> is exactly equivalent to:
> 
> class foo {
>   public:
>     int x, y;
> };
> 
> The only difference between struct and class in C++ is the
> default access specification of its members.
> 
> --
> Neil Cerutti
> For those of you who have children and don't know it, we have a nursery
> downstairs. --Church Bulletin Blooper


And that is what I meant.

hg





More information about the Python-list mailing list