Programming in C/C++ Efficiently
Course 'CS205 C/C++ Program Design' in 2021 Fall at Southern University of Science and Technology. The lecture videos can be found at https://www.bilibili.com/video/BV1Vf4y1P7pq
Why Should You Take This Course?
C and C++ have a big overlap in syntax. The standards of C and C++ are also very long, and still in evolution to accept new features. This course will not cover all aspects of C and C++. It is impossible. The course focuses on the most important and unique parts of C and C++. Pointers and memory management will be described and explained almost through all chapters. They make many beginners even experienced developers crazy for bugs difficult to find. But they are important for computing efficiently, and also are the unique advantages of C and C++. Some people hate them, and some love them. We can say pointers and memory management make C and C++ unique to most other advanced programming languages.
The course is designed for undergraduate students who have learnt Java or Python. If the students taking this course have some background knowledge of programming, such as knowing a little Java or Python, it will be helpful. If not, it is also not a problem.
Chapter 1: Getting Started
- The first example
- Different programming languages
- Compile and link
- Different errors
- Preprocessor and macros
- Simple input and output
- Command line arguments
- Exercises
Chapter 2: Data Types and Arithmetic Operators
- Integer numbers
- Different integer types
- Floating-point numbers
- Constant numbers and constant variables
- Arithmetic operators
- Special notes
Chapter 3: Branching and Looping Statements
if
statement? :
operator- Conditional expressions
while
loopfor
loopgoto
statementswitch
statement
Chapter 4: Data Structures
- Arrays
- Strings
- Structures unions and enumerations
typedef
Chapter 5: Memory and Pointer
- Pointers
- Pointers and arrays
- Allocate memory in C style
- Allocate memory in C++ style
Chapter 6: Basics of Functions
- Functions
- Function parameters
- References
return
statementinline
function
Chapter 7: Advances in Functions
- Default arguments
- Function overloading
- Function templates
- Function pointers and references
- Recursive functions
Chapter 8: Speedup Your Program
- C and C++ with ARM
- Speedup your program
- An example with SIMD and OpenMP
- Avoid memory copy in OpenCV
Chapter 9: Basics of Classes
- Classes and objects
- Constructors and destructors
this
pointerconst
andstatic
members
Chapter 10: Advances in Classes
- Operators in OpenCV
- Operator overloading
- Friend functions
- User defined type conversion
- Increment and decrement operators
Chapter 11: Dynamic Memory Management in Classes
- Some default operations
- An example with dynamic memory
- Solution1: Hard copy
- Solution2: Soft copy
- Smart pointers
Chapter 12: Class Inheritance
- Improve your source code
- Derived class
- Access control
- Virtual functions
- Inheritance and dynamic memory allocation
- Examples in opencv
Chapter 13: Class Templates and std Library
- Class template
- Template non-type parameters
- Class template specialization
std
classes
Chapter 14: Error Handling
- Standard output stream and standard error stream
assert
- Exceptions
- More about exceptions
nothrow
Chapter 15: Nested Classes and RTTI
- Friend classes
- Nested types
- RTTI and type cast operators
Reference
- Mr. Yitong Wang's repo for the course in Fall 2020. https://github.com/YeeTone/CS205-2020Fall
- Mr. Zheng Dong's repo for the course in Fall 2021. https://github.com/XDZhelheim/CS205_C_CPP_Lab
- Mr. Wenqian Yan's repo for the course in Fall 2022. https://github.com/YanWQ-monad/SUSTech_CS205_Projects