C++ 奥斯特雷姆问题
所以我在同一个文件中有两个类<代码>ArrayLink列表和C++ 奥斯特雷姆问题,c++,ostream,C++,Ostream,所以我在同一个文件中有两个类ArrayLink列表和ArrayLink列表 在第一个提到的方法中,我有一个方法 template<class T> friend ostream& operator <<(ostream& s, ArrayLinkedList<T>& ll){ //Extra code for giving s content return s; } template friend ostream
ArrayLink列表
在第一个提到的方法中,我有一个方法
template<class T> friend ostream& operator <<(ostream& s, ArrayLinkedList<T>& ll){
//Extra code for giving s content
return s;
}
template friend ostream&operator尝试删除模板
部分:
friend ostream& operator <<(ostream& s, ArrayLinkedList& ll){
//Extra code for giving s content
return s;
}
// and analogically with ArrayLinkedListRow
friend ostream&operator您能否将问题简化为一个仍然会产生错误的小而完整的示例?ArrayLinkedList
和ArrayLinkedList
之间是否存在某种继承关系?没有继承关系。我会编辑这个问题,这样你就可以看到完整的课堂了。谢谢,我会这样做的。希望它与主程序的其余部分一起工作。有趣的是,ArrayLinkedListRow
工作正常,尽管它在结构上与ArrayLinkedList
基本相同。这是MSVC的另一个“功能”(bug)吗?
template<class DT>
class ArrayLinkedList {
private:
DT* _info[MAX_SIZE]; // store data
int _next[MAX_SIZE]; // next node
int _nextEmpty[MAX_SIZE]; //next empty slot
ArrayClass< ArrayLinkedListRow<DT> >* _rows;
int _head; // head of the list
int _firstEmpty; // first empty slot
int _size;
void copy(const ArrayLinkedList<DT>& ll);//copy from another list
// add a new node with next as it's next node and returns the index of new node
int newNode( DT& newObject, int next);
public:
ArrayLinkedList(); // empty and copy constructors
ArrayLinkedList(const ArrayLinkedList<DT>& ll);
//copy constructors linked list object to an existing object. This is a deep copy.
~ArrayLinkedList(); // destructor
ArrayLinkedList(DT& newObject); // Constructor that create a list with newObject as the head
ArrayLinkedList(int capacity); // Constructor with a give capacity
ArrayLinkedList(DT& newObject,int capacity);// Constructor with newObject as the head and capacity
bool isEmpty(); // is the list empty?
int size(); // return the number of nodes stored
void add(DT& newObject); // add an object to the tail
void insertAt(DT& newObject, int position); // insert an object at the position specified
DT remove(); // remove the head
DT removeAt(int position); // remove an object at the position specified
int find(DT key); // find the object that matches key, index of the object
void operator=(const ArrayLinkedList<DT>& ll); // = operator
// overloading [] operator, return a reference to object at the
// Add a new data element to the start of a linked list.
DT& operator[] (const int position); // position in the linked list
// ostream operator
template<class T> friend ostream& operator <<(ostream& s, ArrayLinkedList<T>& ll){
return s;
}
void displayRaw(); // display raw data of the data members
};
friend ostream& operator <<(ostream& s, ArrayLinkedList& ll){
//Extra code for giving s content
return s;
}
// and analogically with ArrayLinkedListRow