Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C++

การเปลี่ยนแปลงใหม่ใน C++11

C++11 ได้รับการรับรองจาก ISO วันที่ 12 สิงหาคม 2011 เพิ่มฟีเจอร์มากมายใน Core Language

ฟีเจอร์หลักของ C++11

  • nullptr − Null Pointer Literal แทน 0/NULL ป้องกัน Implicit Conversion
  • Lambdas − Anonymous Functions ใช้ได้ทุกที่ที่คาดหวัง std::function
  • Smart Pointers − shared_ptr, unique_ptr, weak_ptr (แทน auto_ptr ที่ Deprecated)
  • auto − Type Deduction ประกาศตัวแปรไม่ต้องระบุ Type
  • Override และ Final − ควบคุม Virtual Function Overriding
  • Deleted และ Defaulted Functions − = delete ปิด Copy, = default ใช้ Default Impl
  • Range-based For Loops − for (auto& x : container) แบบ Foreach
  • Strongly-typed Enums − enum class ไม่ Pollute Scope
  • Static_assert และ Type Traits − Compile-time Assertion
  • New Algorithms − all_of(), any_of(), none_of()

ฟีเจอร์เหล่านี้ทำให้ C++11 เป็นขั้นตอนสำคัญสู่ Modern C++