-----BEGIN PGP SIGNED MESSAGE----- Hello, I hope someone can tell me why the following source produces an error (trapno 14, error 5): ------------------------------------ class BaseClass { public: virtual void print() { printf("BaseClass::print()\n"); }; }; class DerivedClass : public BaseClass { public: virtual void print() { printf("DerivedClass::print()\n"); }; }; DerivedClass dc; void main(void) { BaseClass *bc = &dc; bc->print(); } ---------------------- If dc is defined inside main(), everything works fine. Chris -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Christian Stueble............stueble@ls6.cs.uni-dortmund.de PubKey[BF7104F5].......fp=8678C5D3CAD9CD8C F1DDB8EC202F116A To be or not to be is true... (apocrypha of George Boole) -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.0i for non-commercial use MessageID: Mqyve75goky7Nb6fefYC/Sh3qq9PuiJi Comment: iQCVAwUBOH3OA/yJjJy/cQT1AQEzOQQAut8lc3ns0EgZiQc80OgiKjlgnLv9g4Np bOdvfgxqspDkUqV6j/D/w0I1tJc3QAwLh8EsF4t6K27dd3yqJN2JVEnvud/7wNGh as2+1S1gqhV6k6dttkY5rfPy+epp/e8ZM5jmhFiS0H/HG+F6Vq+wTAm1f3DnWpoX a1mRhzHjZ+g= =fR1c -----END PGP SIGNATURE-----
Christian Stueble <stueble@amaunet.cs.uni-dortmund.de>:
I hope someone can tell me why the following source produces an error (trapno 14, error 5):
If dc is defined inside main(), everything works fine.
It's probably because you have a broken compiler/linker, or are using the wrong options to your compiler/linker. The code works for me. However, I have at times experienced global objects not being initialised, and I have even resorted to replacing "Object x;" by "Object *x = 0;" and preceding each use of x by "if (!x) x = new Object;" ... until I found out how to repair the link line. This is off-topic for l4-hackers, by the way. I suggest we don't discuss this further on the list ... Edmund
participants (2)
-
Christian Stueble -
Edmund GRIMLEY EVANS