Overriding constructors

From: Guillermo Ontañón <gontanon_at_dragon-lance.net>
Date: 01 Feb 2003 17:05:17 +0100

Hi,

I've been looking through the man page for gob, and tried a few things
and connot find the proper way to override a constructor method. The
purpose of this is being able to call the parent's constructor from my
constructor.

GOB won't let me declare the "new" as override, so I guess that's not
the way to do it.

A more concrete example will make my question clearer:

suppose I have class foo:

class foo from G:Object {
        private int a;
        public foo *new (int a) {
                foo *self = GET_NEW;
                self->_priv->a = a;
                return self;
        }
}

Now I want to create a subclass, I would like to provide a constructor
that lets the parent initialize its stuff too:

class fooChild from foo {
        private int b;
        public fooChild *new (int a, int b) {
                fooChild *self = GET_NEW;
                self->_priv->b = b;
                /*
                 * and now I do not know how to call the parent
                 * foo_new (a); would make a whole new object,
                 * but I want foo to get the "a" value
                 */
        }
}

I'm probably missing something here. Any help would be appreciated.

Regards,

-- 
Guillermo Ontañón
gontanon@dragon-lance.net || http://weezer.dragon-lance.net
GRupo de Usuarios de Linux de La Almunia - http://grulla.hispalinux.es
PGP key: 1024D/3AE9EA90 
Fingerprint: EF61 44E1 6725 A343 B165  2CEC 83C2 938B 3AE9 EA90

Received on Sat Feb 01 2003 - 11:05:11 CST

This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:05:02 CDT