#include#include "NodeList.h" int main() { NodeList list; list.push_front(1); list.push_front(2); list.push_front(3); std::cout << "List contains: "; for(auto i : list) { std::cout << i << " "; } std::cout << std::endl; return 0; }
#includeIn this example, we create a list of `Person` objects. The `Person` struct holds a name and age. We create 3 `Person` objects and add them to the front of the list. We then iterate over the list and print the name and age of each `Person` object. The NodeList library is part of the Boost C++ libraries, which is a collection of libraries for C++. Boost provides support for many common programming tasks and can simplify development.#include #include "NodeList.h" struct Person { std::string name; int age; Person(std::string name, int age) : name(name), age(age) {} }; int main() { NodeList list; list.push_front(Person("Alice", 30)); list.push_front(Person("Bob", 25)); list.push_front(Person("Charlie", 20)); std::cout << "List contains: "; for(auto p : list) { std::cout << p.name << " (" << p.age << ") "; } std::cout << std::endl; return 0; }