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

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

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

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

Herb Sutter, Andrei Alexandrescu

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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


Exceptions


When used sparingly and with care, implicit conversions can make calling code short and intuitive. The standard

std::string defines an implicit constructor that takes a

const char* . This works fine because the designers took some precautions:Item 29). This avoids the creation of hidden temporary variables.


Even so, there can still be some weirdness with overloaded functions:

void Display( int );
void Display( std::string );
Display( NULL );

// calls Display(int)

This result might be surprising. (Incidentally, if it did call

Display( std::string ) , the code would have exhibited undefined behavior because it's illegal to construct a

std::string from a null pointer, but its constructor isn't required to check for the null.)


/ 521