[CMU 15-445/645] Project#0 C++ Primer

[CMU 15-445/645] Project#0 C++ Primer

[CMU 15-445/645] Project#0 C++ Primer

Project地址:C++ PRIMER


All the programming projects this semester will be written on the BusTub database management system. This system is written in C++. To ensure that you have the necessary C++ background, we are requiring everyone to complete a simple programming assignment to assess your knowledge of basic C++ features. You will not be given a grade for this project, but you are required to complete the project with a perfect score before being allowed to proceed in the course. Any student that is unable to complete this assignment before the deadline will be asked to drop the course.

All of the code in this programming assignment must be written in C++ (specifically C++ 17). It is generally sufficient to know C++ 11. If you have not used C++ before, here is a short tutorial on the language. More detailed documentation of language internals is available on cppreference. A Tour of C++ and Effective Modern C++ are also digitally available from the CMU library.

这里是说这些项目是基于一个叫做BusTub的数据库管理系统,使用C++ 编写,Project#0是用来测试你的C++ 水平,通过了才能继续完成之后的project。使用的C++ 17,C++ 11也行。需要注意的是该实验是在linux下进行的,windows下可以利用wsl或者虚拟机来进行实验,之后有时间把配置过程补上。

There are many tutorials available to teach you how to use gdb effectively. Here are some that we have found useful:



In this project, you will implement three classes: Matrix, RowMatrix, and RowMatrixOperations. These matrices are simple two-dimensional matrices that must support addition, matrix multiplication, and a simplified General Matrix Multiply (GEMM) operations.

You will only need to modify a single file: p0_starter.h You can find the file in the BusTub repository at src/include/primer/p0_starter.h.

In this header file, we have defined the three classes that you will need to implement. The Matrix abstract class defines the common functions for the derived class RowMatrix. The RowMatrixOperations class will use RowMatrix objects to achieve the operations mentioned in overview. The function prototypes and member variables are specified in the file. The project requires you to fill in the implementations of all the constructors, deconstructors, and member functions. Do not add any additional function prototypes or member variables. You only need to modify the defined functions that we provide you.

The instructor and TAs will not provide any assistance on C++ questions. You can freely use Google or StackOverflow to learn about C++ and any errors you encounter.




If the below git concepts (e.g., repository, merge, pull, fork) do not make sense to you, please spend some time learning git first.

Follow the instruction to setup your own PRIVATE repository and your own development branch. If you have previuosly forked the repository through the GitHub UI (by clicking Fork), PLEASE DO NOT PUSH ANY CODE TO YOUR PUBLIC FORKED REPOSITORY! Make sure your repository is PRIVATE before you git push any of your code.




sudo ./build_support/packages.sh


$ mkdir build
$ cd build
$ cmake ..
$ make



  • Starter: test/primer/starter_test.cpp


$ make starter_test
$ ./test/starter_test

You can also run make check-tests to run ALL of the test cases. Note that some tests are disabled as you have not implemented future projects. You can disable tests in GTest by adding a DISABLED_ prefix to the test name.

These tests are only a subset of the all the tests that we will use to evaluate and grade your project. You should write additional test cases on your own to check the complete functionality of your implementation.

注意如果要进行所有测试需要将测试文件里的 DISABLED_ 前缀全部删除


Your code must follow the Google C++ Style Guide. We use Clang to automatically check the quality of your source code. Your project grade will be zero if your submission fails any of these checks.

Execute the following commands to check your syntax. The format target will automatically correct your code. The check-lint and check-clang-tidy targets will print errors and instruct you how to fix it to conform to our style guide.

使用Google的C++ style,并使用clang来自动化检查代码


$ make format
$ make check-lint
$ make check-clang-tidy


Instead of using printf statements for debugging, use the LOG_* macros for logging information like this:

LOG_INFO("# Pages: %d", num_pages);
LOG_DEBUG("Fetching page %d", page_id);

To enable logging in your project, you will need to reconfigure it like this:

$ mkdir build
$ cd build
$ make

The different logging levels are defined in src/include/common/logger.h. After enabling logging, the logging level defaults to LOG_LEVEL_INFO. Any logging method with a level that is equal to or higher than LOG_LEVEL_INFO (e.g., LOG_INFO, LOG_WARN, LOG_ERROR) will emit logging information. Note that you will need to add #include "common/logger.h" to any file that you want to use the logging infrastructure.





  • src/include/primer/p0_starter.h


这些都是一些基本的C++ 语法,矩阵运算也很简单,主要就是一些C++的特性用的比较多。









unique_ptr(const unique_ptr&) = delete;

unique_ptr 代表这个指针指向的资源只属于一个owner,因此不能直接赋值给其他变量,注意,直接作为函数参数,也是一种赋值,因此必须使用std::move来进行赋值。不能直接赋值。


$ make format 
$ make check-lint 
$ make check-clang-tidy

接着跑本地测试,测试之前需要将测试文件中的 DISABLED_ 前缀删除,不然会有些测试不会run

  • test/primer/starter_test.cpp


  • 本地
  • Gradescope
zip -r p0_submission.zip src/include/primer/p0_starter.h