Weird (?) problem
mike
vertex at gmx.at
Thu Aug 10 06:05:45 PDT 2006
Thanks, it works! :-)
I still need one little workaround, but that's ok.
Funny thing is: Thinking about it a little bit more I got that idea:
' class TypeFoo : TypeBase
' {
' public:
' static this() { instance = new Bar(); }
'
' private:
' void setup() { /* add object, setup */ }
' TypeBase instance;
'
' unittest
' {
' instance.setup();
' }
' }
since the unittest will be executed after ALL static this()'s are done,
and it's the only piece of code that is tied to a class and called
automatically (besides the constructors) - but I don't want to be that
evil :-)
Another question:
Is there a way to prevent a derived class from calling super()? I solved
this currently with an empty this(int) and calling super(0), but is there
another way?
-Mike
Am 10.08.2006, 14:14 Uhr, schrieb Ary Manzana <asterite at gmail.com>:
> Have you tried placing code after "instance = new TypeType()"?
>
> Like this:
>
> ' class TypeType : TypeBase
> ' {
> ' TypeBase instance = null;
> ' static this() {
> ' instance = new TypeType();
> ' // I don't know whether addObject is a function
> ' // or a member of TypeType, but you get the point
> ' instance.addObject("typetype");
> ' instance.getObject("typetype").setType(instance);
> ' }
> ' static TypeBase opCall() { return instance; }
> ' this()
> ' {
> ' }
> ' }
>
> Hope that helps (and works).
> Ary
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
More information about the Digitalmars-d-learn
mailing list