In the first section
C:
const in a = int const a
int *const p
const int *const p
char *p =malloc(100); //(void *)
enum day
{ Mon,TUE } enum DAY today today = 100; int a,b =10; a=b=100; (a=b)=100;//Expressions cannot be assigned
In C++:
1. The type check is stricter
const in a =0; must be initialized
char *p = (char*)malloc(100);
2. Added a BOOL type (ture/false), which is actually an enumerated type
3. The enumeration type in C++ is a real enumeration type, and can only take the content inside
enum BOOL
{ FALSE,TURE } BOOL a = FALSE; (only the value in the enumeration type BOOL can be used)
4. Expression
(a=b)=100;//Expression can be assigned
The second section
cin cout class object. The same function as scanf and sprintf, function
char name[30];
scanf, gets, cin (unsafe)
fgets(name,30,stdin)//control the read length yourself (safe)
string name;
cin>>name (safe)
cin>> stream input operator
Output control
int a =12345;
cout <<setw(8)<<a<<endl; Output width control
cout<<setiosflags(ios::left)<<setw(8)<<endl; Output width
control, left justified
int a =123;
printf("%x",a);hexadecimal
printf("%o",a);octal
printf("%d",a);decimal
cout<<hex<<a; ten Hexadecimal
cout<<oct<<a; octal
cout<<a; decimal
Section III
1. Overloading of functions: the function name is the same, the parameter list is different (, type,
number, order), the
return value type does not constitute an overload condition
2. Matching principle: strict matching, implicit conversion
void print(int a)
void printf(float a)
print(3.4) // The double type
exists (the int type and the float type exist at the same time , there will be ambiguity)
void print(long a)
void printf(double a)
print(3) //int type is in the (long type and double Types exist at the same time,
there will be ambiguity) The
solution is forced to print(long(3))