Re: Lahman, how ya doing?



Gregory L. Hansen wrote:
In article <d5m6lr$q9e$1@xxxxxxxxxxxxxxxxxxxxx>,
Andrew McDonagh  <news@xxxxxx> wrote:

snipped

one over the other, simply implies what default visibility you want.

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 get() method.

In this case, the use of a Class (and actually the use of the 'private:' is ensuring encapsulation - all members are private.

So, is it better than a const struct? I'd say in this example yes, simply because we don't want to expose the other two member vars.

Your Mileage may vary.


Towards the end of my recent message to Lahman I posed a problem where I want to tell an object of one class to get data from an object of another class sometimes from one member function and sometimes from another member function. Except there's no easy way I know of to use a pointer to a member function, so I'd thought of using public variables as an interface. That seems related to what you'd just said above. Any comments on my new shenanigan?


:-)

I've just started reading your thread on comp.lang.c++ but didn't register it was your posting.

it looks like Karl has shown you how to achieve what you want using C++'s idiom of function pointers.

Personal (and YMMV) I find mixing programming paradigms within an application, 'iffy'.

I'd naturally go for an OOP approach to achieve the same aim.

Let me finish reading you post to Lahman and on comp.l.c++ and I'll try and show you how I'd approach it.

Andrew
.