www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/13/21:39:48

Xref: news2.mv.net comp.os.msdos.djgpp:3807
From: GRENDEL AT vm DOT amu DOT edu DOT pl
Newsgroups: comp.os.msdos.djgpp
Subject: signatures - what's going on?
Date: Mon, 13 May 96 15:10:19 CET
Organization: ADAM MICKIEWICZ UNIVERSITY POZNAN
Lines: 49
Message-ID: <17786D55BS86.GRENDEL@vm.amu.edu.pl>
NNTP-Posting-Host: vm.amu.edu.pl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
  I have a signature declared as follows:
  signature SWindow
  { // Here should be curly brace but my mailer coverts it to quote
    void foo();
    void foo1();
    ...
  }
Now, I understand that the advantage of using signatures is that I don't
care whether the given class has been derived from the same base as
another class,as long as they have all the methods specified in the
signature, is that right? So, having this settled I would like to use
pointers to signatures, compare the signatures to the NULL value and,
of course, invoke methods declared in signature - all that without knowing
what is the _ACTUAL_ class of the object I'm reffering to. But it seems that
this doesn't work. Whenever I try to do something of the below I get error
messages from the compiler:
  // SWindow is the signature defined in header file
  SWindow*   wnd;
 
  wnd = NULL; // ERROR
  if( wnd ) // ERROR
when, on the other hand I do the following, everything works just fine:
  // TWindow is a class that conforms to the SWindow declaration
   SWindow*   wnd;
   TWindow*   tmp = NULL;
 
   wnd = tmp;
   if( (tmp = wnd) )
 
what is going on? The way I see it signatures are there to eliminate the
need of such explicit conversions to the specific class, aren't they?
If signatures allowed assigning NULL to pointers to them, comparison of
pointers to the NULL value,it would be possible to write a function, for
example, that would be able to deal with a whole range of classes, not
necessary derived from the same base. The way the signatures work now
makes writing such a code useless, 'cause I'd have to incorporate to the
code specific pointer conversions - and that's what I wanted to avoid.
  Could someone give me a hint on what's wrong, either with my code or
with signatures?
 
N.B. Forgive me if my writing seems cryptic or ungrammatical
 
 
    /*******************************/
    /** SO HERE I AM ONCE MORE... **/
    /*******************************/
 
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019