Skip to content

Commit 838b5f0

Browse files
committed
delegate the initialization of m_root to the default constructor
1 parent bdda0e4 commit 838b5f0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Data_structures/TrieTree/src/TrieTree.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ namespace my {
66

77
// Constructor
88
Trie::Trie()
9-
: m_root(nullptr)
9+
: m_root(new TrieNode())
1010
{
11-
m_root = new TrieNode();
1211
}
1312

1413
// Destructor
@@ -18,10 +17,8 @@ namespace my {
1817
}
1918

2019
Trie::Trie(std::initializer_list<std::string> init_list)
21-
: m_root(nullptr)
20+
: Trie()
2221
{
23-
m_root = new TrieNode();
24-
2522
for (const auto& word : init_list)
2623
{
2724
this->insert(word);

0 commit comments

Comments
 (0)