односвязная цепная печать c ++
Я пытаюсь выбрать свою цепочку в формате {1,2,3,4 и т. Д.}. Вы можете найти файл заголовка ниже, который будет иметь расположение узлов. Я просто запутался в том, как мне следует передвигаться по списку, чтобы распечатать Предмет.
Любое руководство будет с благодарностью!
set.h
using namespace std;
#include <iostream>
class Set
{
private:
struct Node
{
int Item; // User data item
Node * Succ; // Link to the node's successor
};
unsigned Num; // Current count of items in the set
Node * Head; // Link to the head of the chain
public:
// Return information about the set
//
bool is_empty() const { return Num == 0; }
unsigned size() const { return Num; }
// Initialize the set to empty
//
Set();
// Insert a specified item into the set, if possible
//
bool insert( int );
// Display the set
//
void display( ostream& ) const;
};