Using STL lists to store data
STL is a standard template library that contains a lot of implementations of the basic data structures, which means we can directly use them for our purpose. The list is internally implemented as a doubly linked list, which means insertion and deletion can happen at both ends.
Getting ready
For this recipe, you will need a Windows machine with a working copy of Visual Studio.
How to do it…
In this recipe, we will see how we can easily use the inbuilt template library provided for us by C++ to create complex data structures. After the complex data structure has been created, we can easily use it to store data and access it:
Open Visual Studio.
Create a new C++ project.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#include <iostream> #include <list> #include <conio.h> using namespace std; int main() { list<int> possible_paths; possible_paths.push_back(1); possible_paths.push_back(1); possible_paths.push_back...