Re: About the private member
- From: pek <kimwlias@xxxxxxxxx>
- Date: Wed, 26 Nov 2008 15:36:32 -0800 (PST)
On Nov 27, 12:53 am, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
Martin Gregorie wrote:
On Wed, 26 Nov 2008 08:01:28 -0800, pek wrote:
OK.. Now I kinda get it. But is there anybody out there that actually
used this type of code? Is it just Java or OO in general? Either case,
where does this help?
I do that all the time in both Java and ANSI C:
include "example.h" /* contains function prototypes */
int _global; /* Underscore restricts scope to this file */
void example(int g)
_global = g;
which is more or less exactly equivalent to a Java singleton with a
parameterised constructor and a getter. If more than one "instance" is
needed per program, its easy to define the globals in a struct and to
name it with a typedef. The 'constructor' function mallocs space for it
and returns a pointer. It is freed by a "destructor". The pointer is
passed to all the other functions in just the same way that FILE*
pointers get passed to file handling library functions.
I think you'll find a lot of people use a similar approach to writing C..
Its close enough to OO for translating between this form of C source
module and a Java class to be a fairly straight forward process.
Underscore does what ?
I thought you used static for that ?
Sooooo.... This is not that useful (or cool) as it sounded right?
Indeed, I have only seen this in the equals method.
- Prev by Date: Re: Minnesota Recount
- Next by Date: Re: About the private member
- Previous by thread: Re: About the private member
- Next by thread: Re: About the private member