Course 'CS205 C/C++ Program Design' in 2021 Fall at Southern University of Science and Technology.
<, <=, >, >=, ==, !=
- a calculator?
- Makefile (how to manage multiple source files using a Makefile)
- create an array and the element is of a structure
- cmake (automatically generate a Makefile according to the environment).
- Read from a binary, and print out in tex format
- How to debug using VS Code.
const int * p; int * const p;
- null pointer, random pointer
- out of range
- memory leak
- allocate memory for an array string, modify elements by integer values one by one, then print out the result as a string. Please try to modify the element out of range and see what will happen.
- an example to test integer arguments, pointer argument and reference arguments
- implement a function with default arguments.
- overload a function which can compute the absolute value for an array, the array can be int, float and double
vabs(int * p, int n); //should n be int or size_t, what's the difference, please create an arrary with more than 2^31 elements
vabs(float * p, int n);
vabs(float * p, int n);
Create two 1Mx1K float matrices matA and matB, compute matA + matB.
- compute the result row by row and col by col, compare the performance difference
- use -O3 to improve the speed
- improve the speed using SIMD, will the speed be improved? Why?
- build-in types and user defined types
- data componient and method/functions
- Access control: public and private
- Create an object and access members
- const member functions
- const member variables
- static member variables
- Constructors
- Default Constructors
- Destructors
- Initialization
Create a simple class. Please try to test:
- access a private member
- modify a const data member
- modify a data member in a const function
- initializate a const data member
Constructor and assignment
Student s2=s1;
Student s3;
s3=s1;
overload + and << for your own defined class
- Default constructor
- Copy constructor
- Assign operator
- Default destructor
- How pointer members work defaultly
Create a class for matrices which elements are in float. The class should support the follow operations and has no memory management problem. When a matrix is assigned to another by =, the two matrices will share the same data.
class Matrix{...};
Matrix a(3,4);
Matrix b(3,4);
Matrix c = a + b;
Matrix d = a * 2.0f;
- Constructor
- Destructor
Create a matrix template class which can handle different data types.