I am a newbie to C++ and am self-learning the databases course at CMU. In the second programming project, we implement a B+ tree index. We have a BPlusTreePage
class which has two children class BPlusTreeInternalPage
and BPlusTreeLeafPage
. The way the skeleton code handles generic class confuses me.
In b_plus_tree_internal_page.h
:
template <typename KeyType, typename ValueType, typename KeyComparator>
class BPlusTreeInternalPage : public BPlusTreePage {...};
In b_plus_tree_internal_page.cpp
:
...
// valuetype for internalNode should be page id_t
template class BPlusTreeInternalPage<GenericKey<4>, page_id_t, GenericComparator<4>>;
template class BPlusTreeInternalPage<GenericKey<8>, page_id_t, GenericComparator<8>>;
template class BPlusTreeInternalPage<GenericKey<16>, page_id_t, GenericComparator<16>>;
template class BPlusTreeInternalPage<GenericKey<32>, page_id_t, GenericComparator<32>>;
template class BPlusTreeInternalPage<GenericKey<64>, page_id_t, GenericComparator<64>>;
I'm wondering what does these lines starting with template class
do? In my understanding, the code should just work without those lines, but I'm not sure if I'm correct. Thanks for helping!