src/str.cc

changeset 82
841562f5a32f
parent 79
2425fa6a4f21
child 85
264a61e9eba0
equal deleted inserted replaced
81:071715c17296 82:841562f5a32f
295 return string (a) + b; 295 return string (a) + b;
296 } 296 }
297 297
298 // ============================================================================= 298 // =============================================================================
299 // 299 //
300 string string::operator+ (const string data) const 300 string string::operator+ (const string& data) const
301 { 301 {
302 string newString = *this; 302 string newString = *this;
303 newString += data; 303 newString += data;
304 return newString; 304 return newString;
305 } 305 }
313 return newstr; 313 return newstr;
314 } 314 }
315 315
316 // ============================================================================= 316 // =============================================================================
317 // 317 //
318 string string::operator+ (int num) const
319 {
320 string newstr = *this;
321 string numstr;
322 numstr.sprintf ("%d", num);
323 newstr += numstr;
324 return newstr;
325 }
326
327 // =============================================================================
328 //
318 string& string::operator+= (const string data) 329 string& string::operator+= (const string data)
319 { 330 {
320 append (data); 331 append (data);
321 return *this; 332 return *this;
322 } 333 }
325 // 336 //
326 string& string::operator+= (const char* data) 337 string& string::operator+= (const char* data)
327 { 338 {
328 append (data); 339 append (data);
329 return *this; 340 return *this;
341 }
342
343 // =============================================================================
344 //
345 string& string::operator+= (int num)
346 {
347 string numstr;
348 numstr.sprintf ("%d", num);
349 return operator+= (numstr);
330 } 350 }
331 351
332 // ============================================================================= 352 // =============================================================================
333 // 353 //
334 bool string::is_numeric() const 354 bool string::is_numeric() const

mercurial