C++ Language

Under CentOS system

Installation C ++ compiler g ++: yum install gcc-c ++

We can also use the g ++ C files before compiling, and gcc compiler command similar, but the gcc instead of g ++.

 

O: In c we use printf scanf for input and output, this syntax is still applicable in C ++. g ++ also added new cin and cout libraries for input and output.

 

Add a C ++ type bool: Value true and false, occupying 1 byte size. Such as: bool b; b = true; if (b) {printf ( "this is true \ n");}

 

When C ++ may be applicable for the variable loop directly defined in statement: for (int i = 0; i <10; i ++) {}. i variable must be defined outside the previous C: int i; for (i = 0; i <10; i ++) {}

 

C ++ default parameters: In C ++ function definition time if there are a number of parameters you can set default parameters, set a default value to the parameter, if the function is called when there is no default parameter settings incoming defaults apply. Such as:

void func (you val = 1);

int main ()

{

  func();

}

void func(int val)

{

  printf("val=%d\n",val);

}

Note: The default parameters can only be placed behind the non-default parameters

 

C ++ dynamic memory allocation: use in C malloc () and free () function of dynamic memory allocation and release, is still available in C ++, but also provides two new keywords new and delete to allocate and free memory.

Guess you like

Origin www.cnblogs.com/maycpou/p/12557974.html