Should NRObject and the like be 'struct' or 'class'?
$ grep NRObject /Volumes/Ben/PROG/SF/INKSCAPE/inkscape-P/src/libnr/nr-object.h struct NRObject; struct NRObjectClass; #define NR_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_OBJECT, NRObject)) #define NR_OBJECT_GET_CLASS(ip) (((NRObject *) ip)->klass) void (* cinit) (NRObjectClass *), void (* iinit) (NRObject *)); /* NRObject */ class NRObject : public Inkscape::GC::Managed<>, NRObjectClass *klass; static NRObject *alloc(NRType type); static void invoke_ctor(NRObject *object) { NRObject *reference() { NRObject *unreference() { NRObject() {} NRObject(NRObject const &); // no copy void operator=(NRObject const &); // no assign struct NRObjectClass { ...
I'm fairly sure that it doesn't matter, but I just wondered whether we should stick to one or the other. I work on the basis that a C++ struct has all members public, but can have methods and virtual methods if needed or desirable; even so, I tend not to use that keyword except for C compatibility, that is when there are in fact no methods in the class, and I would guess no vptr either.
See http://www.parashift.com/c++-faq-lite/classes-and-objects.html#faq-7.8 http://groups.google.co.uk/group/comp.lang.c++/browse_thread/thread/20f6e046...
If I had to choose, it'd probably be 'class'.
-mental
On 28/07/06, MenTaLguY <mental@...3...> wrote:
If I had to choose, it'd probably be 'class'.
I have a preference for using class (for C++ objects), but this might be situation in which 'struct' is better. I'll make a patch.
See http://www.research.att.com/~bs/bs_faq.html#class .
I'm not claiming to be bothered a great deal by this, it came up when I turned on -Wabi as suggested at http://www.cocoadev.com/index.pl?XCodeTips . I've a feeling that this warns on every 'empty class', and I am not sure that this is good idea.
Ben
participants (2)
-
Ben Fowler
-
MenTaLguY