c++知識點

sworsman31415926發表於2020-12-16

 

一、C++介紹

    本賈尼·斯特勞斯特盧普,與1979年4月份貝爾實驗室的本賈尼博士在分析UNIX系統分佈核心流量分析時,
希望有一種有效的更加模組化的工具。
 1979年10月完成了前處理器Cpre,為C增加了類機制,也就是物件導向,1983年完成了C++的第一個版本,
C with classes也就是C++。
    C++與C的不同點:
 1、C++基本相容C的語法(內容)
 2、支援物件導向的程式設計思想
 3、支援運算子過載
 4、支援泛型程式設計、模板
 5、支援異常處理
 6、型別檢查嚴格


二、第一個C++程式

 1、副檔名
        .cpp .cc .C .cxx
 2、編譯器
        g++ 大多數系統需要額外安裝,Ubuntu系統下的安裝命令:
            sudo apt-get update
            sudo apt-get install g++
        gcc也可以繼續使用,但需要增加引數 -xC++ -lstdc++
    補充說明:以下引自 
https://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc

gcc and g++ are compiler-drivers of the GNU Compiler Collection (which was once upon a time just 
the GNU C Compiler).
Even though they automatically determine which backends (cc1 cc1plus ...) to