🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #32

Re: wywolanie

#32
From: jst...
Date: Wed, 08 Oct 1997 00:00
38 lines
1608 bytes
In article <61gb75$s...@zeus.polsl.gliwice.pl>,
  pio...@zeus.polsl.gliwice.pl (Piotr Auksztulewicz) wrote:
>
> LUBLIN (oo...@telbank.pl) wrote:
> : Pytanie dotyczy wlasciwie C++, ale moze tu znajde na nie odpowiedz...
> : Zagadka :
>
> : jak wywolac druga z metod zadeklarowana jako
>
> : char* f();
> : const char* f() const;
>
> : w pewnym obiekcie (wcale nie statycznym) ?
> : Domyslnie kompilator korzysta z pierwszej...
>
> No w�a�nie. Te� mia�em taki problem. U mnie by�o co� takiego:
>
> char & operator [] (int); [1]
> const char & operator [] (int) const; [2]

Mozna tak:
 A a;  //Nasz klasa z oboma "wersjami" funkcji f.
 a.f();                //Zwykle f
 ((const A)a).f();  //f const;
 ((const A*)&a)->f();  //Albo tez tak -f const;

 oraz tak samo

 i=a[2];  //Non-const oper.
 i=((const A)a)[2];  //const-oper.

Z powazaniem,

Janusz Stopa

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
Technical Details
Message-ID: <876364489.22015@dejanews.com>
Path: mbox-mo1.pugleaf.net!unknown!not-for-mail
References: <61g35e$28g@info.nask.pl> <61gb75$sta@zeus.polsl.gliwice.pl>

Show Full Headers
Complete Article Headers
From: jst...@bear.com
Subject: Re: wywolanie
Date: 1997/10/08
Message-ID: <876364489.22015@dejanews.com>
X-Deja-AN: 278864790
References: <61g35e$28g@info.nask.pl> <61gb75$sta@zeus.polsl.gliwice.pl>
X-Http-User-Agent: Mozilla/3.0 (WinNT; U)
X-Originating-IP-Addr: 207.159.107.86 (proxy1.bear.com)
Organization: Deja News Posting Service
X-Authenticated-Sender: jst...@bear.com
X-Article-Creation-Date: Thu Oct 09 02:34:50 1997 GMT
Newsgroups: pl.comp.lang.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit