[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] C++ spørgsmål - hvad gårgalt med minstring?



On Wed, 18 Apr 2001, Jonas Christian Drewsen wrote:

> > string tmp = (*i).first.AsString();
> > 
> > At indføre en tmp ting, hjalp;
> > ged tmpged = (*i).first;
> > string tmp = tmpged.AsString();
> > virkede.
> > 
> > Men, hvorfor? (Har forsøgt med andre ()).
> 
> Hvis din instans af klassen ged, som ligger i (*i).first, er
> af typen
> "const ged", vil c++ kigge i klassen ged efter en function
> der hedder
> "string AsString() const". 

Jeg har ikke skrevet const nogen steder omkring ged... 

> Du har kun defineret en der hedder
> "string
> AsString()". Ved at sætte "const" efter
> funktions-definitionen/-erklæringen angiver du at et objekt
> af typen
> ged, kan kalde denne funktion selv når objektet er const.

Men, hvad betyder det i denne sammenhæng at det er const?

> 
> Dette forklarer også at du kan kalde funktionen når du
> kopierer objektet
> over i et nyt tmp objekt. Det nye tmp objekt er ikke af typen
> const, og
> kan derfor sagtens kalde AsString().

Bliver ting der bliver indsat i et map til const?

Tak for svaret, iøvrigt.

Mads


-- 
Mads Bondo Dydensborg.                               sslug@sslug
It is strange to claim that video games should influence children. If for
example Pac-Man influenced children born in the 1980'ies, then today we
would have a lot of young people jumping around in dark rooms, eating pills
while listening to monotome music

          - Anonym



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *