Pagina 1 di 1

[C++] Errore "should have been declared"

MessaggioInviato: 26/04/2018, 12:36
da Amabuzi
Ho un problema, sto implementando una serie di funzioni per far funzionare un dizionario basato su alberi di ricerca binari, ho scritto tutto e quando compilo mi da il seguente errore:
"should have been declared inside dict" con le funzioni insertElem, deleteElem, print, search e createEmptyDict.
Metto di seguito il codice che ho scritto nel file header per una maggiore comprensione dell'errore, spero possiate aiutarmi.

#include <iostream>
#include <stdexcept>
#include <vector>
#include <fstream>
#include <chrono>
#include <stdlib.h>
#include <string>

#include "string-utility.h"

using namespace std::chrono;
using namespace std;

namespace dict {

//Casi di errore

enum Error {OK, FAIL};

//Tipi e Costanti

const int tableDim = 1000; //da modificare per esperimenti diversi

typedef string Key; //tipo base
typedef string Value; //tipo base

const Key emptyKey = "###RESERVED KEYWORD### EMPTY KEY"
const Value emptyValue = "###RESERVED KEYWORD### EMPTY VALUE"

typedef struct {
Key key;
Value value;
} Elem;

struct AlBST {
Elem e;
AlBST *lchild, *rchild, *father;
};
typedef AlBST* Dictionary;

struct t_stack {
Dictionary val;
t_stack *next;
};
typedef t_stack *ptr_stack;

Error insertElem(const Key, const Value, const Dictionary&);
Error deleteElem(const Key, const Dictionary&);
Value search(const Key, const Dictionary&);
Dictionary createEmptyDict();
void print (const Dictionary&);
}

Grazie mille per il tempo che mi dedicherete.

Re: [C++] Errore "should have been declared"

MessaggioInviato: 26/04/2018, 15:27
da claudio86
A parte i punti e virgola dopo le due costanti, e commentando la linea #include "string-utility.h", compila tranquillamente. Sarebbe utile che mostrassi tutto il sorgente e soprattutto tutto l'output del compilatore.