[Click] strange string

Koen Segers koen.segers at edpnet.be
Tue Apr 4 19:12:29 EDT 2006


Hi,

I just found something strange.
I've created a function called add_detailed_info that has a String parameter.
When I call this function in the following manner, it doesn't compile. 

_dump->add_detailed_info("Hello with xid=" + _info->get_network_id() + " and 
seqnr=" + _info->get_broadcast_seqnr() + " and size=" + 
_info->get_network_size());

Compiling this gives:
elements/pdhcp/pdhcp_hello_generator.cc:105: error: invalid operands of 
   types `const char*' and `const char[12]' to binary `operator+'


When I change it to the following, all works wonderful. 
String str = "Hello with xid=";
		str += _info->get_network_id();
		str += " and seqnr=";
		str += _info->get_broadcast_seqnr();
		str += " and size=";
		str += _info->get_network_size();
		_dump->add_detailed_info(str);


Now the question is, how is this possible?
I saw that the string class has overloaded the operator+ for many cases. Is 
there a case missing for what I'm trying to do? Or maybe the operator()?

xid is a uint32_t
broadcast_seqnr = int
network_size = int

greetz
-- 

Koen Segers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : https://amsterdam.lcs.mit.edu/pipermail/click/attachments/20060404/8217a1cd/attachment.pgp


More information about the click mailing list