Rép : superclasses and subclasses

Never mind, I forgot the static_cast<CustomMolecule *> term… Anyways, sorry for the emails…

Marc

Le 14 jun 2013 à 07:16, Marc-André Dubois ma.dubois@me.com a écrit :

Hi guys,
I want to make a subclass of Avogadro::Molecule. Can I do that kind of association?

superclass: Molecule
subclass: CustomMolecule

Molecule *parent = gl->molecule();
CustomMolecule *child = parent;

(gl is the GLWidget). I know this seems to be an easy question, but I face some problems and I am not so familiar with C++… Thanks,

Marc

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

Oops, I missed this – apparently GMail doesn’t recognize the "Rép"
prefix as a reply :wink:

static_cast will work, but it’s less safe. It doesn’t do any checking
to see if the pointee is actually the type you’re attempting to
convert it to – it just does the conversion.

See this page for more info:

http://www.cplusplus.com/doc/tutorial/typecasting/

Dave

On Fri, Jun 14, 2013 at 8:13 AM, Marc-André Dubois ma.dubois@me.com wrote:

Never mind, I forgot the static_cast<CustomMolecule *> term… Anyways,
sorry for the emails…

Marc

Le 14 jun 2013 à 07:16, Marc-André Dubois ma.dubois@me.com a écrit :

Hi guys,
I want to make a subclass of Avogadro::Molecule. Can I do that
kind of association?

superclass: Molecule
subclass: CustomMolecule

Molecule *parent = gl->molecule();
CustomMolecule *child = parent;

(gl is the GLWidget). I know this seems to be an easy question, but I face
some problems and I am not so familiar with C++… Thanks,

Marc

This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-devel


This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-devel