私はこの割り当てに取り組んでいますが、明らかに以前に宣言されたメソッドに対してエラーが発生し続けています。.h ファイルは次のとおりです。
#ifndef DLLIST_H
#define DLLIST_H
#include <iostream>
#include <fstream>
#include <cstddef>
#include "DListNode.h"
typedef int ItemType;
class DLList
{
private:
friend std::ostream & operator<< (std::ostream & out, DLList & other);
int size;
int * head;
int * tail;
void _copy(const DLList * toCopy);
void _dealloc();
public:
DLList();
DLList(const DLList & toCopy);
~DLList();
DLList & operator=(const DLList & toCopy);
int size();
void append(ItemType item);
void insert(int index, ItemType item);
ItemType pop(int index);
ItemType pop();
const DListNode & operator[] (int idx);
};
std::ostream & operator<< (std::ostream & out, const DLList & d);
#endif
int size();
以前の宣言と競合しているとのエラーが で発生しています。これは通常、このヘッダー ファイルを複数回インクルードすることで発生することはわかっていますが、どこで発生しているのかわかりません。これらは、プロジェクト内のすべてのファイルの include ステートメントです。
#include "DLList.h" // DLList.cpp
=======================================
#include "DListNode.h" // DListNode.cpp
=======================================
#include <iostream> // DListNode.h
#include <fstream>
#include <cstddef>
=======================================
#include "DLList.h" // This is the main test file
#include "DListNode.h"
#include <iostream>
DListNode.h が技術的に 2 回インクルードされていることがわかりますが、DLList.h が複数回インクルードされている場所はありません。私は愚かな間違いを犯していて、それを見ていませんか?(おそらくそうです)。助けてくれてありがとう!