Article View: de.comp.lang.c++
Article #871Re: Funktionszeiger auf Klassenmethoden
From: Roland Minde
Date: Tue, 21 Nov 1995 14:15
Date: Tue, 21 Nov 1995 14:15
36 lines
1557 bytes
1557 bytes
This is a multi-part message in MIME format.
---------------------------------43232605012758
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1
Hallo Andi
Natürlich kann man auch Member-Function-Pointer haben.
Der Aufruf einer Memberfunktion geht aber stets nur mit einem Objekt.
Siehe nachfolgendes Beispiel, ausprobiert nach Beispielen
aus Ellis, Stroustrup; The Annotated C++ Reference Manual; §8.1c
---------------------------------43232605012758
Content-Transfer-Encoding: 7bit
Content-Type: zz-application/zz-winassoc-C
#include <iostream.h>
struct S
{
int f(char*);
int i;
S(): i(13) {}
};
int S::f(char* st) { cout <<st <<endl; return i; }
main()
{ S s;
int* ip =&s.i; // ip points to s's member i
int S::* sip =&S::i; // sip get offset of `i' in an S
cout <<"Use ip=" <<*ip <<endl;
//cout <<"Use sip=" <<*(&s+sip);
int (S::*pmf)(char*) =&S::f; // Pointer to member Function
int j =(s.*pmf)("hallo");
}
---------------------------------43232605012758--
Technical Details
Message-ID:
<48smum$ngm@horus.mch.sni.de>Path:
arc1-ca.pugleaf.net!horus.mch.sni.de!newsReferences:
<48fv1i$paf@sparcserver.lrz-muenchen.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!horus.mch.sni.de!news From: Roland Minde <Roland.Minde@cgk.sni.de> Newsgroups: de.comp.lang.c++ Subject: Re: Funktionszeiger auf Klassenmethoden Date: 21 Nov 1995 14:15:50 GMT Organization: SNI Message-ID: <48smum$ngm@horus.mch.sni.de> References: <48fv1i$paf@sparcserver.lrz-muenchen.de> NNTP-Posting-Host: sys168.cgk.sni.de Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="-------------------------------43232605012758" X-Mailer: Mozilla 1.22 (Windows; I; 16bit)