Introduction to C++

LT1 Intro to programming

Computer: Motherboard + CPU + RAM (Primary Storage) + Secondary Storage

Programming Languages

  1. Machine Language (Binary Code): Directly executable by computer
  2. Symbolic Language (*Assembly Language): Abbrivs representing elementary operations
  3. High-Level Language: Closer to human language. eg C, C++, Java

Building a C++ Program

  1. Writing source code -> CPP file
  2. Preprocessing: process the source code for compilation: Preprocessor Directives
  3. Compilation: Syntax check, Generate Object Code from source
  4. Linking: Combine object code and libraries to create an executable

Differences between programming languages

  1. Syntax
  2. Libraries, SDK, Functions

Programming

  1. Develop the logic
  2. Implement into programming language
  3. Testing

which requires

  1. Correct syntax & logic
  2. Efficiency, Scalability, Maintainability

Computer program

  1. From the External View, the basic elements are
    Input -> Process -> Output

  2. From the Internal View, the computer program is

    • Logically ordered Instructions + Data (Variables & Constants)

A Simple Program

Preprocessor Directive
#include <iostream> // Include the library into the program
using namespace std; // Preprocessor Directive std::cout -> cout (shorthand name)
Functions

Left Brace { and Right Brace } marks the beginning and end of the func body

Library / SDK / Package

The wheels made for reuse, especially for repeating tasks / low-level operations.
e.g.: <iostream>, <iomanip>
The reusing code is well designed and packed into Libraries
Standard C++ comes with extensive libraries

Object An instance of a class

cout<<"Hello, workd!\n";

cout is an object provided by iostream library for screen output

<<: output operator outputs values to the output device, ie cout

Object is a unit that stores values and provides functions for the values.

An abstract from the real world

A simple C++ Program

#include <iostream> // Preprocessor Directive

using namespace std; // Namespace Declaration

int main(){ // Beginning of main() function body 
    cout<< "Hello, world!\n"; // starting point of the main function, use output operator << of cout object
    return 0; //return statement 
} 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市咨油,隨后出現(xiàn)的幾起案子窿冯,更是在濱河造成了極大的恐慌芥驳,老刑警劉巖麸粮,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蛮放,死亡現(xiàn)場離奇詭異拍皮,居然都是意外死亡撵割,警方通過查閱死者的電腦和手機贿堰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來啡彬,“玉大人羹与,你說我怎么就攤上這事∈樱” “怎么了纵搁?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長往踢。 經(jīng)常有香客問我腾誉,道長,這世上最難降的妖魔是什么峻呕? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任利职,我火速辦了婚禮,結(jié)果婚禮上瘦癌,老公的妹妹穿的比我還像新娘猪贪。我一直安慰自己,他們只是感情好讯私,可當(dāng)我...
    茶點故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布哮伟。 她就那樣靜靜地躺著,像睡著了一般妄帘。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上池凄,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天抡驼,我揣著相機與錄音,去河邊找鬼肿仑。 笑死致盟,一個胖子當(dāng)著我的面吹牛碎税,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播馏锡,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼雷蹂,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了杯道?” 一聲冷哼從身側(cè)響起匪煌,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎党巾,沒想到半個月后萎庭,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡齿拂,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年驳规,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片署海。...
    茶點故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡吗购,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出砸狞,到底是詐尸還是另有隱情捻勉,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布趾代,位于F島的核電站贯底,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏撒强。R本人自食惡果不足惜禽捆,卻給世界環(huán)境...
    茶點故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望飘哨。 院中可真熱鬧胚想,春花似錦、人聲如沸芽隆。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽胚吁。三九已至牙躺,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間腕扶,已是汗流浹背孽拷。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留半抱,地道東北人脓恕。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓膜宋,卻偏偏與公主長得像,于是被迫代替她去往敵國和親炼幔。 傳聞我的和親對象是個殘疾皇子秋茫,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內(nèi)容