Introduction to C++
2641 ワード
LT1 Intro to programming
Computer: Motherboard + CPU + RAM (Primary Storage) + Secondary Storage
Programming Languages Machine Language (Binary Code): Directly executable by computer Symbolic Language (*Assembly Language): Abbrivs representing elementary operations High-Level Language: Closer to human language. eg C, C++, Java
Building a C++ Program Writing source code -> CPP file Preprocessing: process the source code for compilation: Preprocessor Directives Compilation: Syntax check, Generate Object Code from source Linking: Combine object code and libraries to create an executable
Differences between programming languages Syntax Libraries, SDK, Functions
Programming Develop the logic Implement into programming language Testing
which requires Correct syntax & logic Efficiency, Scalability, Maintainability
Computer program From the External View, the basic elements are Input -> Process -> Output From the Internal View, the computer program is Logically ordered Instructions + Data (Variables & Constants)
A Simple Program
Preprocessor Directive
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.:
Object An instance of a class
Object is a unit that stores values and provides functions for the values.
An abstract from the real world
A simple C++ Program
Computer: Motherboard + CPU + RAM (Primary Storage) + Secondary Storage
Programming Languages
Building a C++ Program
Differences between programming languages
Programming
which requires
Computer program
A Simple Program
Preprocessor Directive
#include // 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.:
,
The reusing code is well designed and packed into Libraries Standard C++ comes with extensive libraries Object An instance of a class
cout<
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 // Preprocessor Directive
using namespace std; // Namespace Declaration
int main(){ // Beginning of main() function body
cout<< "Hello, world!
"; // starting point of the main function, use output operator << of cout object
return 0; //return statement
}