[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: [PROGRAMMERING] Forstaaelse problemmer i c++



> 2008/3/18 Allan W. Nielsen <sslug@sslug>:
>
>> Hej
>>
>> Jeg er igang med at lave wet lille project i c++, og er l/obet ind i et
>> lille problem.
>>
>> F/olgende program illustrerer problemet:
>>
>> #include <string>
>> using namespace std;
>>
>> int main(){
>>  string s1;
>>  string s2();
>>
>>  s1 = "test af s1";
>>  s2 = "test af s2"; //compiler fejl her
>>  //her er fejlen
>>  //test.cpp: In function 'int main()':
>>  //test.cpp:11: error: assignment of function 'std::string s2()'
>>  //test.cpp:11: error: cannot convert 'const char [11]' to
>>  //             'std::string ()()' in assignment
>>
>>  return 0;
>> }
>>
>> Jeg trode at de 2 variable defineringer gjorde det samme, eller med
>> andre
>> ord at default constructorn altid blev kaldt, og at default
>> constructoren
>> er constructoren der ikke tager nogen argumenter.
>>
>> Haaber der er nogen der ude som kan forklare hvad der endtlig sker, og
>> hvorfor
>>
>> MVH
>> Allan W. Nielsen
>>
>>
> Så vidt jeg husker string, så laver du i den først et  string-object og
> initialisere dette til at indeholde "Test af s1".
> I den anden opretter du en tom streng  og  denne prøver du at  sætte til
> at
> være lig med en række chars. Prøv evt at skrive string() omkring dine
> chars
> i  s2 assignment,
>
> /Lasse
>
>
> !DSPAM:47e0098095306491211187!
>

Hej

Jeg haar samme svar tilbage, naar jeg aendre
s2 = "test af s2";
til
s2 = string("test af s2");

Og jeg forstaar stadig ikke fejl beskrivelsen... hvad er en string()()
 ??

MVH
Allan W. Nielsen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-04-01, 02:01 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] *