Chapter 2 C Language
1. C and C ++
2. Compatibility between C and C ++
3. c ++ features not supported by C
4. Differences between functions and C ++ in C: function Overloading is not supported.
5. function parameter check
6. Function Definition
7. Call C in C ++ and call C ++ in C
8. function pointer
View code /*
//
// This is example code from Chapter 27.2.4 "pointers to functions"
// "Programming -- Principles and Practice Using C ++" by Bjarne stroustrup
//
*/
/*----------------------------------------------------------------------------*/
Struct shape1 {
Enum kind {circle, rectangle} kind;
/*...*/
};
/*----------------------------------------------------------------------------*/
Void draw (struct shape1 * P)
{
Switch (p-> kind ){
Case circle:
/* Draw as circle */
Break;
Case rectangle:
/* Draw as rectangle */
Break;
}
}
/*----------------------------------------------------------------------------*/
Int F (struct shape1 * pp)
{
Draw (PP );
/*...*/
}
/*----------------------------------------------------------------------------*/
Typedef void (* pfct0) (struct shape2 *);
Typedef void (* pfct1int) (struct shape2 *, INT );
/*----------------------------------------------------------------------------*/
Struct shape2 {
Pfct0 draw;
Pfct1int rotate;
/*...*/
};
/*----------------------------------------------------------------------------*/
Void draw1 (struct shape2 * P)
{
(P-> draw) (p );
}
/*----------------------------------------------------------------------------*/
Void rotate (struct shape2 * P)
{
(P-> rotate) (p, 90 );
}
/*----------------------------------------------------------------------------*/
Int F1 (struct shape * pp)
{
Draw (PP );
/*...*/
}
/*----------------------------------------------------------------------------*/
9. Differences in the C/C ++ structure signature Space
10. Differences in keywords between C/C ++
11. Differences in variable definition between C/C ++
12. C style type conversion
13. Void * Conversion
14. Enumeration
15. namespace
16. Dynamic Memory Allocation
17. cStyle string
18. C-style string and const
19. byte operations
20. instance: strcpy
21. style issues
22. Input and Output
23. File
24. constants and macros
25. Macro
26. Macro of Class Functions
27. Do not use syntax macros
28. Conditional compilation