C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources] - نسخه متنی

Herb Sutter, Andrei Alexandrescu

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


Examples


Example: An implementation of

+=

for strings.
When concatenating strings, it is useful to know the length in advance so as to allocate memory only once.

String& String::operator+=( const String& rhs ) {

// … implementation …
return *this;
}
String operator+( const String& lhs, const String& rhs ) {
String temp;

// initially empty
temp.Reserve( lhs.size() + rhs.size() );

// allocate enough memory
return (temp += lhs) += rhs;

// append the strings and return
}


/ 521