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

Standard Libraries ใน C++ คืออะไร?

ในภาษา C++ C++ Standard Library เป็น collection ของ classes และ functions ที่เขียนใน core language และเป็นส่วนของ C++ ISO Standard เอง C++ Standard Library 提供 generic containers หลายตัว, functions สำหรับใช้และจัดการ containers, function objects, generic strings และ streams (รวม interactive และ file I/O), support สำหรับบาง language features, และ functions สำหรับ everyday tasks เช่น หารากที่สองของตัวเลข คุณสมบัติบางส่วนของ C++ standard library:

  • Streams – Libraries สำหรับจัดการ streams ต่างๆ ใน C++ เช่น fstream สำหรับ file stream สร้างไฟล์ เขียน/อ่านข้อมูล, sstream สำหรับ string stream manipulate strings ฯลฯ
  • Containers – Collection ของ classes เก็บข้อมูลใน data types ต่างๆ เช่น vectors, sets, maps, stacks, queue เป็น component ของ STL
  • General libraries – Libraries เช่น algorithm, Chrono สำหรับเวลา, iterator, memory ฯลฯ
  • Numerics library – Collection ของ components สำหรับ seminumerical operations เช่น <complex> สำหรับ complex numbers, <random> สำหรับ random numbers ฯลฯ
  • Threading – Library เพิ่มใน C++11 จัดการ concurrency
  • C Standard Library – Header ทุกตัวจาก C Standard Library รวมอยู่ใน C++ Standard Library ภายใต้ชื่อต่างกัน โดยลบ .h และเติม c นำหน้า เช่น time.h → ctime

โปรดทราบว่า Standard libraries ใน C++ แตกต่างจาก Standard Template Library (STL) ซึ่งเป็น subset ของ Standard Library