From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3658 invoked by alias); 3 Feb 2014 17:37:16 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 3647 invoked by uid 89); 3 Feb 2014 17:37:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: postina.bo.infn.it Received: from postina.bo.infn.it (HELO postina.bo.infn.it) (131.154.11.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 03 Feb 2014 17:37:12 +0000 Received: from pamina.bo.infn.it (pamina.bo.infn.it [131.154.10.143]) (authenticated bits=0) by postina.bo.infn.it (8.14.5/8.14.5) with ESMTP id s13Hb6nD026721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 3 Feb 2014 18:37:06 +0100 Message-ID: <52EFD3C2.6030209@bo.infn.it> Date: Mon, 03 Feb 2014 17:37:00 -0000 From: Graziano Servizi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: question Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00018.txt.bz2 How could this (included) very short code work? It isn't a NOT SAFE conversion that made inside void fun? How can the A pointer know about the B's member f() ? I'm using gcc 4.8.2 on a Linux Fedora 19 system. Thanks for your help. G. Servizi Code follows: # include using namespace std; class A {/*omissis*/}; class B : public A {/*omissis*/ public: void f( ){cout<<"bye\n";}}; void fun(A *a) { B *b = static_cast(a); b -> f( ); } int main( ) { A *a = new A; fun(a); }