Re: Lahman, how ya doing?



In article <d5iuj1$pl7$1@xxxxxxxxxxxxxxxxxxxxx>,
Andrew McDonagh <news@xxxxxx> wrote:
>Gregory L. Hansen wrote:
>> In article <0%Qde.43511$4v.31435@trndny03>,
>> H. S. Lahman <hsl@xxxxxxxxxxxxxxxxx> wrote:
>>
>>>Responding to Hansen...
>>
>>
>>>class EventElement
>>>{
>>>private:
>>> Object* recipient;
>>> int event_id;
>>> int tick_count;
>>>public:
>>> EventElement (Object* r, int e, int t)
>>> {recipient = r; event_id = e; tick_count = t;};
>>> int getTickCount() {return tick_count;};
>>>}
>>
>>
>> Let me ask you, why is this a class? I usually think of classes as
>> something with member functions that do things with the data. I would
>> have used a struct as a passive holder of data.
>>
>>
>
>For one thing, it allows us to create instances which are immutable objects.
>
>For another, we can use polymorphic calls with a class over a struct
>('c' struct I take it you mean - as C++ structs are the same as Classes
>but with different default access rights).

Thanks, Andrew, but I'm not sure that meant anything to me.

Immutable objects? Can't be changed? Is that better than a const struct?

I could use more words on the second paragraph, if you don't mind. Why
is a polymorphic call with a class over a struct a good thing?

--
"The polhode rolls without slipping on the herpolhode lying in the
invariable plane." -- Goldstein, Classical Mechanics 2nd. ed., p207.
.



Relevant Pages

  • Re: Array.Sort a struct
    ... They will,by default, choose a struct over a class for a Plain Old ... alot of them in tight looping situations. ... potential performance improvement comes from faster creation of the struct ... immutable objects that you create frequently and it is effecting ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Array.Sort a struct
    ... They will,by default, choose a struct over a class for a Plain Old Datatype. ... immutable objects ... The important thing to note is that it is the cost of creation that you are saving. ... His struct is small but not Tiny (more expensive method calls). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Lahman, how ya doing?
    ... Object* recipient; int event_id; ... we can use polymorphic calls with a class over a struct. ... In the case of the Class code above, whilst the EventElement is created with three parameters, only tick_count is accessible to other objects, as its the only member var with a getmethod. ...
    (comp.object)