🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #9118

constante pointers C++

#9118
From: Agaricus
Date: Fri, 24 May 2002 15:12
31 lines
1598 bytes
Hallo,

Ik probeer het volgende


#include <iostream.h>

void main (void)
{
 int a = 3;
 int * const ptr = &a;

 cout << "a : " << a << endl;
 cout << "address a : " << &a << endl << endl;

 cout << "inhoud pointer : " << *ptr << endl;
 // output : 3

 cout << "adres in pointer : " << ptr << endl;
 // output : adres van a

 cout << "adres van de pointer : " << &ptr << endl;
 // output :  foutmelding
}

als foutmelding krijg ik illegal structure operation.

Kan iemand me uitleggen waarom je geen adres kan nemen van die pointer
? En hoe kan je dat dan wel doen als het eventueel mogenlijk zou zijn?

Agaricus
Technical Details
Message-ID: <tplseukgkmgasjoh3vat3kpb4rji1iugl4@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!news.chello.be.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,244e7c66b4db59c2,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-05-24 08:13:52 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!news.chello.be.POSTED!not-for-mail
From: Agaricus <AgaricuswebmailNOSPAM@yahoo.com>
Newsgroups: be.comp.programming
Subject: constante pointers C++
Message-ID: <tplseukgkmgasjoh3vat3kpb4rji1iugl4@4ax.com>
X-Newsreader: Forte Agent 1.9/32.560
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 31
Date: Fri, 24 May 2002 17:12:06 +0200
NNTP-Posting-Host: 213.132.139.89
X-Complaints-To: abuse@chello.be
X-Trace: news.chello.be 1022253230 213.132.139.89 (Fri, 24 May 2002 17:13:50 MET DST)
NNTP-Posting-Date: Fri, 24 May 2002 17:13:50 MET DST
Organization: Chello Belgium Usenet Service