From 4750383458820378798
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,b0cd8398b44a1f95,start
X-Google-Attributes: gidf78e5,public
From: Mike Austin <m.austin@ix.netcom.com>
Subject: Can't convert function pointers where arguments are a subclass?
Date: 2000/03/08
Message-ID: <38C60A5E.ED4829BF@ix.netcom.com>#1/1
X-Deja-AN: 594649724
Content-transfer-encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Accept-Language: en
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 952511224 mail2news:38 mail2news mail2news.demon.co.uk
Organization: SBC Internet Services
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
MIME-version: 1.0
NNTP-Posting-Date: Wed, 08 Mar 2000 00:07:50 PST
Newsgroups: comp.std.c++

I can see that one way would let RenderMessage act upon a Message and
cause problems, but what about the other way around?  An base object
pointer is safe to operate on a derived class.  As an example:

struct Message { };
struct RenderMsg : Message { };

class Visual {
 public:
    virtual void Render1( RenderMsg *msg ) { }
    virtual void Render2( Message *msg ) { }
};

void (Visual::*method1)( Message* ) = &Visual::Render1;
void (Visual::*method2)( RenderMsg* ) = &Visual::Render2;

Neither of the last two lines compile.


Mike

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




