У меня есть домашнее задание, в котором заголовочный файл предоставляется нам и не подлежит изменению. Мне сложно понять, как правильно использовать функцию "display", поэтому вот соответствующий код.
Заголовочный файл:
#ifndef SET_
#define SET_
typedef int EType;
using namespace std;
#include <iostream>
class Set
{
private:
struct Node
{
EType Item; // User data item
Node * Succ; // Link to the node's successor
};
unsigned Num; // Number of user data items in the set
Node * Head; // Link to the head of the chain
public:
// Various functions performed on the set
// Display the contents of the set
//
void display( ostream& ) const;
};
#endif
Вот моя реализация функции "display":
void Set::display( ostream& Out ) const
{
Node * temp = Head;
cout << "{ ";
while( temp != NULL )
{
cout << temp << ", ";
temp = temp->Succ;
return Out;
}
}
А вот мой драйвер:
#include <iostream>
#include <iomanip>
#include "/user/cse232/Projects/project08.set.h"
using namespace std;
int main()
{
Set X;
X.insert(10);
X.insert(20);
X.insert(30);
X.insert(40);
X.display();
}
Ошибка, которую я получаю, говорит о том, что в моем драйвере я не использую правильные параметры. Я понимаю это, потому что файл .h использует ostream & в качестве параметра. У меня вопрос: что я использую в своем файле драйвера при вызове "display" в качестве хорошего параметра?