🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.c++
Article #1432

Re: void* - Felder

#1432
From: Karl-Heinz Krause
Date: Sat, 27 Jan 1996 09:59
36 lines
1166 bytes
Am 26. Jan. 1996 schrieb Andrea Hermann
(hermann@ipf.bau-verm.uni-karlsruhe.de):

> Hi, 
> ich habe hier ein Programmfragment, von dem ich nicht weiss,
> wieso es nicht tut:

> int main()
> {
>     void* feld;
>     int   typ;

>     // typ  fuer int, 2 fuer double,...

>     switch( typ )
>     {
>         case 1: f ( void* ) new int[n];
                  ^
Du meinst wohl:  feld new int[n];
Das explizite casten nach void* ist nicht erforderlich.

>                 for( int i ; i < n; i++ )
>                     ein >> (int)f[i];

richtig:  ein >> ((int*)feld)[i];

>                 break;

>         // andere Faelee
>      }
>      return 0;
> }



Karl-Heinz Krause
Technical Details
Message-ID: <4ed0hn$9mf@news00.btx.dtag.de>
Path: arc1-ca.pugleaf.net!news00.btx.dtag.de!not-for-mail!Krause
References: <3109142F.41C67EA6@ipf.bau-verm.uni-karlsruhe.de>

Show Full Headers
Complete Article Headers
Newsgroups: de.comp.lang.c++
Message-ID: <4ed0hn$9mf@news00.btx.dtag.de>
From: Krause@t-online.de (Karl-Heinz Krause)
Path: arc1-ca.pugleaf.net!news00.btx.dtag.de!not-for-mail!Krause
Subject: Re: void* - Felder
Date: Sat, 27 Jan 1996 09:59:03 +0000
References: <3109142F.41C67EA6@ipf.bau-verm.uni-karlsruhe.de>
X-Gateway: ZCONNECT XX ius.gun.de [UNIX/Connect v0.73]
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit