We get to that point, c++, this chapter mainly introduce parts of c++, and understand them with many code example.
hello world
first program "hello world", using std
cin
and out
. 1
2
3
4
5
6
7
8
int main()
{
using std::cout;
using std::endl;// only use the 2 elements in standard namespace
cout << "Hello Buggy World \n";
return 0;
}
brief introduction of fuction
first touch of function in c++ 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using namespace std;
int ConsoleOutputTemp();
int main()
{
ConsoleOutputTemp();
return 0;
}
int ConsoleOutputTemp()
{
cout << "this is a simple string literal" << endl;
cout << "number 5 " << 5 << endl;
cout << "math problem 10/5 " << 10 / 5 << endl;
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using namespace std;
int FuncInputDemoOne();
int main()
{
return FuncInputDemoOne();
}
int FuncInputDemoOne()
{
int inputNumber;
string inputName;
cout << "enter an integer " << endl;
cin >>inputNumber;
cout << "enter your name " << endl;
cin >> inputName;
cout << inputNumber << " " << inputName << endl;
return 0;
}++i
will increment the value of i
, and then return the incremented value.
1
2
3
i = 1;
j = ++i;
(i is 2, j is 2)
i++
will increment the value ofi
, but return the original value thati
held before being incremented.1
2
3i = 1;
j = i++;
(i is 2, j is 1)