[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
 

c++ og strings



hej venner

jeg er ved at blive lidt irriteret, så jeg håber I kan hjælpe mig.

Jeg sidder med et kdevelop projekt, og jeg har besluttet at lave nogle
af klasserne QT-uafhængige. Så derfor er jeg begyndt at bruge
string-klassen.

Jeg generede et lille testprogram:

#include <iostream.h>
#include <string>

int main(int argc, char *argv[])
{
  cout << "Hello, World!" << endl;

        string str("and a lot of stuff");
        cout << str << endl;
        
        str += "fddd";
        cout << str << endl;
        
  return EXIT_SUCCESS;
}

Og der virker som det skal. Og nu til den function som er begravet i en 
klasse (og jeg har inkludere string og iostream.h)

...
void XML_template::VersionText()
{
        string output("something");

        output  = "XML_template class v. " + CurrentVersion + "\n";
        output += "Build date is " + __DATE__;
        
        cout << output;

}
...

Og jeg får så 
...
In file included from morlog.all_cpp.cpp:3:
xmltemplate.cpp: In method `void XML_template::VersionText()':
xmltemplate.cpp:51: invalid operands `const char[23]' and `char *' to 
binary `operator +'
xmltemplate.cpp:52: invalid operands `const char[15]' and `const
char[12]' 
to binary `operator +'
...

Det lader til at den har glemt at overloade +-operatoren.
Der er noget galt, det var derfor at jeg lavede test programmet, for at 
vide om det bare var mig der havde en begynder fejl med strings, men det
lod det ikke til at være.

Har I nogen forslag til hvad der er galt? 
mvh
morten

-- 
Morten <sslug@sslug>



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 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] *