again, "was not declared in this scope"

I stuck with these errors,and I really hope someone could help me.
(I don't understand why MTPREDICATE_CLASS is ok, and MTPREDICATE_AND_CLASS, MTPREDICATE_OR_CLASS,MTPREDICATE_NOT_CLASS are not.They are defined in a same file)
Thank u in advance.

MTpredicate.h: In member function ‘virtual GiSTobjid AndPred::IsA()’:
MTpredicate.h:97: error: ‘MTPREDICATE_AND_CLASS’ was not declared in this scope
MTpredicate.h: In member function ‘virtual GiSTobjid OrPred::IsA()’:
MTpredicate.h:137: error: ‘MTPREDICATE_OR_CLASS’ was not declared in this scope
MTpredicate.h: In member function ‘virtual GiSTobjid NotPred::IsA()’:
MTpredicate.h:178: error: ‘MTPREDICATE_NOT_CLASS’ was not declared in this scope

MTpredicate.h:

#ifndef MTPREDICATE_H
#define MTPREDICATE_H

#include "MTobject.h"

//class GiSTentry;

typedef enum {
FUZZY_STANDARD,
FUZZY_ALGEBRAIC
} language;

typedef enum {
LINEAR,
EXPONENTIAL,
DISTR
} dist2sim;

extern language query_language;

double Dist2Sim(double dist);
double Sim2Dist(double sim);

class MTpred: public GiSTobject { // the base class for predicates
public:
virtual GiSTobjid IsA() { return MTPREDICATE_CLASS; }
...
};

class Pred: public MTpred { // a simple predicate
public:
...
GiSTobjid IsA() { return MTPREDICATE_CLASS; }
...
};

class AndPred: public MTpred { // a conjunction of two predicates
public:
...
GiSTobjid IsA() { return MTPREDICATE_AND_CLASS; }
...
};

class OrPred: public MTpred { // a disjunction of two predicates
public:
...
GiSTobjid IsA() { return MTPREDICATE_OR_CLASS; }
...
};

class NotPred: public MTpred { // a negated predicate
public:
...
GiSTobjid IsA() { return MTPREDICATE_NOT_CLASS; }
...
};




the objects MTPREDICATE_AND_CLASS,MTPREDICATE_OR_CLASS,MTPREDICATE_NOT_CLASS are defined in GISTdefs.h:


#ifndef GISTDEFS_H
#define GISTDEFS_H

#include <assert.h>
#include <stdlib.h>
#include <math.h>

#ifdef PRINTING_OBJECTS
#include <iostream.h>
#endif

typedef unsigned long GiSTpage;
typedef enum {
GISTOBJECT_CLASS,
GIST_CLASS,
BT_CLASS,
RT_CLASS,
MT_CLASS,
GISTENTRY_CLASS,
GISTNODE_CLASS,
BTNODE_CLASS,
BTENTRY_CLASS,
BTKEY_CLASS,
RTNODE_CLASS,
RTENTRY_CLASS,
RTKEY_CLASS,
MTNODE_CLASS,
MTENTRY_CLASS,
MTKEY_CLASS,
GISTPREDICATE_CLASS,
BTPREDICATE_CLASS,
RTPREDICATE_CLASS,
MTPREDICATE_CLASS,
MTPREDICATE_AND_CLASS,
MTPREDICATE_OR_CLASS,
MTPREDICATE_NOT_CLASS,

GISTCURSOR_CLASS
} GiSTobjid;

// GiSTobject is the base class for all GiST classes
// It provides identity, equality tests and display of objects

class GiSTobject
{ ...};
Last edited on
I don't see MTpredicate.h including GISTdefs.h.
@helios
Thanks for ur reply.But even I include it, it won't work.
closed account (S6k9GNh0)
...The compiler CHEATS.

I dunno to be honest. I can't seem to find the bug.
Last edited on
closed account (z05DSL3A)
I have only given it a quick look but...
"...was not declared in this scope..." would suggest that you need to use scope resolution on your return

virtual GiSTobjid IsA() { return GiSTobjid::MTPREDICATE_CLASS; }


That's probably wrong, it is probably something funky with your includes, what is in "MTobject.h"?
Last edited on
@computerquip : thanks anyway
@Grey Wolf: thanks for ur reply.nothing special with MTobject:


#ifndef MTOBJECT_H
#define MTOBJECT_H

extern int compdists;
extern int dimension;

#ifndef MIN
#define MIN(x, y) ((x<y)? (x): (y))
#define MAX(x, y) ((x>y)? (x): (y))
#endif

#include <stdio.h>
#include "GiSTdefs.h"
class Object : public GiSTobject // the DB object class
{
public:
...
#ifdef PRINTING_OBJECTS
void Print(ostream& os) const;
#endif
};

...

#endif


closed account (z05DSL3A)
Nothing springs out at me, the only thing that looks odd is MTpredicate.h looks like it needs to include GISTdefs.h and is doing so via including MTobject.h. I can't see why MTpredicate.h needs MTobject.h, so you could try changing it to GISTdefs.h.

1
2
3
4
5
6
#ifndef MTPREDICATE_H
#define MTPREDICATE_H

//#include "MTobject.h"
#include "GISTdefs.h"
//... 


@Grey Wolf: thanks. I've tried it, but it still didn't work. The codes actually are very very old (written in 2000), I don't think it's compatible with the current compiler.I'm going to try to run it on an older machine.Thanks again.
Topic archived. No new replies allowed.