[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år galt med minstring?



Mads Bondo Dydensborg wrote:
> 
> uOn Tue, 17 Apr 2001, Mads Bondo Dydensborg wrote:
> 
> > Hejsa
> >
> > Jeg får følgende fejl;
> >
> > inputconsumer.cc:395: no matching function for call to `keyboard_inputevent_event_t::AsString () const'
> > inputkeyboard.hh:76: candidates are: class string keyboard_inputevent_event_t::AsString() <near match>
> >
> > Hmm. Hvad er det lige jeg gør galt?
> >
> > Det er basalt set et
> > string tmp = object.AsString();
> 
> Det var det så ikke alligevel. Det var en iterator fra et map der var
> derefereret;
> 
> 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". 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.

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().

\Jonas Drewsen


 
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] *