ヘッダー ファイルが提供され、変更できない宿題があります。「表示」機能を正しく使用する方法を理解するのに苦労しているので、関連するコードを次に示します。
ヘッダー ファイル:
#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
関数「表示」の私の実装は次のとおりです。
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" を呼び出すときに、ドライバー ファイルで何を使用すればよいかということです。