Re: Subclassing pfNode

New Message Reply Date view Thread view Subject view Author view

Simon Mills (simon++at++wgs.estec.esa.nl)
Fri, 16 Jul 1999 17:43:10 +0200


Charlie Curry wrote:
>
> I'm just a newbie, but I think the problem is that you are not
> initializing the superclass, pfNode. As they taught me when I learned
> Java, the first line of your constructor should always be super(/*blah*/);
> This is the equivalent of
>
> pfSoundSource::pfSoundSource() : pfNode(/*blah*/)
> {
> /* more stuff */
> }
>
> Check out the documentation for pfNode, and you'll see that IT has no
> default constructor. If you just write...
>
> pfSoundSource::pfSoundSource()
> {
>
> It implies...
>
> pfSoundSource::pfSoundSource() : pfNode()
> {
>
> but that call does not exist.

Yes, thanks I also came to realize that too. The trouble is it isn't
helping me. Does any C++ expert out there know the right C++ trick to
get it to work? I've tried adding my own empty pfNode constructor but it
won't compile. The workaround for now is to subclass pfGroup which works
OK but wasn't what I wanted.

> Good luck,
> Charlie Curry
>
> On Thu, 15 Jul 1999, Simon Mills wrote:
>
> > Hi,
> >
> > I'm trying to subclass pfNode to make my own (sound) pfNode type. It
> > works if I subclass a pfGroup but I'm having trouble compiling if I use
> > pfNode. The error I get is:
> >
> > "../pfSoundSource.c++", line 27: error(1264): no default constructor
> > exists
> > for class "pfNode"
> > {
> >
> > ... and this is the relevant code parts:
> >
> > ----- pfSoundSource.c++ ------
> >
> > #include <Performer/pf/pfNode.h>
> > #include <Performer/pr/pfMemory.h>
> > #include <Performer/pr/pfLinMath.h>
> > #include <Performer/pf/pfTraverser.h>
> > #include "pfSoundSource.h"
> >
> >
> > pfType *pfSoundSource::classType = NULL;
> >
> >
> > void
> > pfSoundSource::init() /* Define class type */
> > {
> > if (classType == NULL) {
> > pfNode::init();
> > classType = new pfType(pfNode::getClassType(), "pfSoundSource");
> > }
> > }
> >
> >
> > pfSoundSource::pfSoundSource(char *fName) // Constructor with loading
> > {
> > pfMemory::setType(classType);
> >
> > /* Initialise properties */
> > ...
> > }
> >
> > ---- end pfSoundSource.c++ -----
> >
> > ---- pfSoundSource.h ----
> >
> > class pfSoundSource : public pfNode
> > {
> > private:
> > static pfType *classType;
> >
> > private:
> > ...
> >
> > public: /* constructor/destructor */
> > pfSoundSource(); // without loading (default)
> > pfSoundSource(char *fName); // with loading
> > ~pfSoundSource(void);
> >
> > public: /* type */
> > static void init();
> > static pfType *getClassType() { return classType; }
> >
> > }
> >
> > ---- end pfSoundSource.h ----
> >
> >
> > Does anyone know what I'm doing wrong or recognise this problem? I've
> > followed the recommendations in the Performer Programming Guide but I
> > guess I'm missing something because pfNode is only a container class.
> >
  
Help!
Simon
________________________________________________________________________

Simon C. Mills
Modelling & Simulation Section (TOS-EMM) Tel: +31 (0)71 565 3725
European Space Agency (ESA/ESTEC) Fax: +31 (0)71 565 5419
Postbus 299, 2200AG Noordwijk e-mail: simon++at++wgs.estec.esa.nl
The Netherlands http://www.estec.esa.nl/wmwww/EMM
________________________________________________________________________


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Fri Jul 16 1999 - 08:43:21 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.