class Car { private: string make; string model; int year; public: Car(string make, string model, int year) { this->make = make; this->model = model; this->year = year; } string getMake() { return make; } string getModel() { return model; } int getYear() { return year; } };
class Node { public: int value; Node* next; Node(int value) { this->value = value; this->next = nullptr; } }; class LinkedList { private: Node* head; public: LinkedList() { this->head = nullptr; } void add(int value) { Node* newNode = new Node(value); if (head == nullptr) { head = newNode; } else { Node* curr = head; while (curr->next != nullptr) { curr = curr->next; } curr->next = newNode; } } void print() { Node* curr = head; while (curr != nullptr) { cout << curr->value << " "; curr = curr->next; } cout << endl; } };In this example, we define a Node class that represents an individual node in a linked list, and a LinkedList class that provides methods for adding nodes to the list and printing the values in the list. We use a pointer to the head node to keep track of the start of the list. Package/Library: Standard Library (for `cout`), potentially library specific to linked lists for `nullptr`).