1, in C + +, a program through the g++ compiler of four steps:
pretreatment g++ Tect.cpp-o test.i-e
Compiling g++ test.i-o test.s-s
Compilation g++ Test.s-o test.o-c
Link g++ test.o-o Test
Execute statement after:./test
2, C and C + + relations:
Learning any new language must think about what has been learned, find similarities and differences, and facilitate learning the characteristics of a new language.
C + + meaning: Plus Plus
C + + is fully compatible with the C language, and many of these features can be reflected.
C:. C stdio.h printf The scanf function is not overloaded, and the struct cannot be an empty procedure
C + +:. cpp iostream (Introduction namespace) cout Cin has overloads, and the class can be empty to emphasize an object
C Program:
#include <stdio.h> void main (void) {int i = 10; printf ("i =%d\n", i);}
C + + programs:
#include <iostream>using namespace Std;int main (void) {int i = 10; Cout<<i<<endl;}
The output of C + + does not emphasize the format of the output, which is automatically recognized by the compiler to Endl carriage return to newline.
Simple differences between 3, C, and C + +:
(1), the created file type is different, C language is. C, C + + is. cpp
(2), the introduction of the header file is not the same
(3), C + + has a namespace
(4), input and output statements are not the same
(5), C language does not allow overloading, C + + can be overloaded
(6), the custom type is different, the C language uses the struct,c++ to use the class
(7), C + + language has logical data type bool
4, C, and C + + compilation Recognition:
The C-language variable must be placed before all valid statements.
When the C + + language uses the variable, in the definition, the comparison conforms to the human culture.
5, C and C + + programming Ideas:
C function + Algorithmic programming emphasizes the process of implementation .
C + + because it is fully compatible with C, its definition variables are not like Java, all objects, int i; this is just a normal variable, so C + + is an object-oriented language.
Object + Object +.................+ algorithm
Talk about C + + Everything to use the object programming emphasizes the object of what, everything around the object
6, in C + + for a number of identical functions of the simple identification method:
(1), using the condition macro
#define Aaa#ifdef AAA void Fun () {} #else void Fun () {} #endif
(2), the use of namespaces to solve:
#include <iostream>using namespace std;namespace myspace{void Fun () {cout<< ' this MySpace ' << ; Endl; }};namespace youspace{void Fun () {cout<< ' this youspace ' <<endl; }};using namespace Myspace;int main (void) {fun (); return 0;}
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/84/52/wKiom1eNWceTe-fTAACLd08JIN0234.png-wh_500x0-wm_3 -wmp_4-s_108929552.png "title=" Qq20160719063354.png "alt=" Wkiom1enwcete-ftaacld08jin0234.png-wh_50 "/>
This is the same call problem that solves the function through the namespace, and of course, the nature and usage of the namespace is not very clear to me when I first touch C + +.
C transition to C + +