Привет, Я пытаюсь решить эту ошибку, которую я получаю, когда пытаюсь передать Связанный список другому классу, который у меня есть. Я просмотрел другие вопросы, но не из них, похоже, исправить эту проблему.Как решить «Недопустимое использование неполного типа« класс SLLNode »« Связанные списки
Мне также нужно SLLNode, чтобы остаться в ListAsSLL, потому что он является родителем для других классов
DynamicSizeMatrix должен иметь агрегацию к ListAsSLL
Мой DynamicSizeMatrix.cpp файл
#include "DynamicSizeMatrix.h"
#include<iostream>
#include<string>
#include<cassert>
#include<cstdlib>
#include"ListAsSLL.h"
using namespace std;
DynamicSizeMatrix::DynamicSizeMatrix(SLLNode* sll,int r, int *c)
{
rws = r;
col = new int [rws];
for(int x=0; x < rws; x++) // sets the different row sizes
{
col[x] = c[x];
}
SLLNode *node = sll ;
// node = sll.head;
*info = new SLLNode*[rws];
for (int x= 0; x< rws;x++)
{
info[x] = new SLLNode*[col[x]];
}
for(int x=0;x<rws;x++)
{
for(int y=0;y<col[x];y++)
{
info[x][y] = node;
node = node->next; // My error happens here
}
}
}
мой «DynamicSizeMatrix.h»
#include"ListAsSLL.h"
#include "ListAsDLL.h"
#include"Matrix.h"
#include"Object.h"
class SLLNode;
class DynamicSizeMatrix : public Matrix
{
private:
SLLNode*** info;
//Object* colmns;
int rws;
int *col; //array of column sizes
// int size;
public:
DynamicSizeMatrix()
{
info = 0;
rws = 0;
col = 0;
}
DynamicSizeMatrix(SLLNode* sll,int r, int *c);
//......
a й «ListAsSLL.h»
class ListAsSLL : public List
{
//friend class LLIterator;
friend class DynamicSizeMatrix;
protected:
struct SLLNode
{
Object* info;
SLLNode* next;
// SLLNode(Object *e, ListAsSLL::SLLNode* ptr = 0);
};
SLLNode* head;
SLLNode* tail;
SLLNode* cpos; //current postion;
int count;
public:
ListAsSLL();
~ListAsSLL();
//////////////
Заранее спасибо
'SSLNode' объявлен как вложенная класса' ListAsSLL', но форвард объявлен вне этой области. Извлеките его из области ListAsSLL. –