Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » error C2110: '+' : cannot add two pointers
Re: error C2110: '+' : cannot add two pointers [message #30447 is a reply to message #30445] Sat, 01 January 2011 19:09 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Neil!

The problem is that there is no operator that would allow to add two const char*. Usually as in your case, those are literal strings so it is not much of a problem since you can always write "ab" instead of "a" + "b". For Upp::String (and for std::string too) there are various operators that allow for operations with both other Strings and const char*.

Also note that there are some other tricks that can help in some situations:
String s,str;
const char* c="something";

s="a"+"b";       //fails
s="a" "b";       //works

s="a"+"b"+str;   //fails
s="a"+("b"+str); //works

s=c+c;           //fails
s=String(c)+c;   //works

The first one is not so known property of C, which was probably designed to allow splitting long strings on multiple lines Smile The second and third are simple, you sure understand what happens there Wink
 
Read Message
Read Message
Read Message
Previous Topic: Multiple users over LAN
Next Topic: U++ Geom package information.
Goto Forum:
  


Current Time: Thu Jun 06 11:17:25 CEST 2024

Total time taken to generate the page: 0.02252 seconds