Я пытаюсь создать упорядоченный список на C++, но он не распознает тип структуры узла в функции insert. Извините за то, что вы назвали не на английском языке некоторые переменные, такие как testa и inserimento, которые являются главой и вводят.Упорядоченный список в C++
LISTA.CPP
#include <iostream>
#include "Lista.h"
#include <stddef.h>
using namespace std;
void insert(){
Lista l;
inserimento->next = NULL;
cout<<"inserisci elemento"<<"\n";
cin>>inserimento->num;
if(testa==NULL){
inserimento->next=NULL;
testa=inserimento;
}
else
{
if(testa->num > inserimento->num) //insert on head
{
inserimento->next = testa;
testa = inserimento;
}
else
{
temp = testa;
while(temp->next != NULL && temp->next->num < inserimento->num)
temp = temp->next;
if(temp->next == NULL) //insert on least
{
temp->next = inserimento;
}
else //insert between
{
inserimento->next = temp->next;
temp->next = inserimento;
}
}
}
}
LISTA.H
#ifndef LISTA_H_
#define LISTA_H_
#include <stddef.h>
namespace std{
class Lista {
public:
struct nodo{
struct node *next ;
int num ;
};
nodo *temp = NULL;
nodo *testa = NULL;
nodo *inserimento = NULL;
void insert(nodo);
};
}
#endif /* LISTA_H_ */
Заранее спасибо
Отредактируйте ваш код правильно, если вы хотите, чтобы другие люди его читали. И описать проблему более подробно. – interjay
'Lista :: nodo :: next' имеет тип' node' - выглядит как опечатка, не так ли? Nodo'? – tomse