Becoming an expert won’t happen overnight, but with a little patience, you’ll get there.
Programming Languages
Machine Language
Assembly Language
High-level Languages
- compiler
- interpreter
Most languages can be compiled or interpreted, however, traditionally languages like C, C++, and Pascal are compiled, whereas “scripting” languages like Perl and
Javascript
tend to be interpreted. Some languages, like Java, use a mix of the two.
C/C++
-
C++ (pronounced see plus plus) was developed by Bjarne Stroustrup at Bell Labs as an extension to C, starting in 1979.
-
C++’s claim to fame results primarily from the fact that it is an object-oriented language.
-
C++ was standardized in 1998 by the ISO committee .
-
C++ excels in situations where high performance and precise control over memory and other resources is needed.
Introduction to C++ development
First Program
#include <iostream>
int main(){
std::cout << "Hello World!";
return 0;
}
> g++ .\01_test.cc -o 01_test
> .\01_test.exe
Introduction to objects and variables
Data
data is any information that can be moved, processed, or stored by a computer.
Objects and variables
In order to create a variable, we use a special kind of declaration statement called a definition .
int x; // define a variable named x, of type int
Data types
Variable assignment and initialization
assignment
#include <iostream>
int main()
{
int width;
width = 5; // copy assignment of value 5 into variable width
// variable width now has value 5
width = 7; // change value stored in variable width to 7
// variable width now has value 7
return 0;
}
initailization
int a; // no initializer
int b = 5; // initializer after equals sign; Copy initialization
int c( 6 ); // initializer in parenthesis; Direct initialization
int d { 7 }; // initializer in braces; Brace initialization
Introduction to iostream: cout, cin, and endl
std::endl vs ‘\n’
Using std::endl can be a bit inefficient, as it actually does two jobs:
- it moves the cursor to the next line
- it “flushes” the output
eg:
#include <iostream>
int main(){
int x;
std::cin >> x;
std::cout << x;
return 0;
}
cin | cout |
---|---|
12 | 12 |
fdffd | 0 |
12fjlakj | 12 |
Introduction to literals and operators
- A literal (also known as a literal constant) is a fixed value that has been inserted directly into the source code.
- In mathematics, an operation is a mathematical calculation involving zero or more input values (called operands) that produces a new value (called an output value).
- Operators in C++ come in three different arities:
- unary
- binary
- ternary
Introduction to expressions
An expression is a combination of literals, variables, operators, and function calls that can be executed to produce a singular value.
人呢?都是跟自己较真过不去。
我也不知道我为什么要非要看英文的学习。
但就是一边自我怀疑,一边硬着头皮学。