Hi everyone,
I'm working on a Red-Black Binary Tree project that's using (or trying to) the standard bitset class.
When I try to declare a bitset inside a struct that belongs to the RBTree class (or anyother place in the class) i get this message from the compiler (I'm using Dev-C++, newest version, in Windows)
ISO C++ forbids declaration of `bitset' with no type
First I though it was some syntax error, but I ran a code where the bitset isn't inside a class and it worked.
So I looked up for a sample that used bitset inside a class, and I got the same error message.
(this is the sample code)
Anyone knows if this is just a Dev-C++ thing or am I doing something wrong?
My code:
Code:
#include <iostream>
#include <exception>
#include <bitset>
#define cor 0
#define corp 1
#define Fdir 2
#define Fesq 3
#define Pdir 4
#define Pesq 5
#define folha 6
#define root 7
#ifndef _RBTree_
#define _RBTree_ 1
class TRBTreeError: public std::exception{
public:
TRBTreeError (char *msg){
printf("[RBTreeError]: %s\n",msg);
}
};
class TRBTree{
enum TraversingDir {
sdInOrder,
sdPreOrder,
sdPosOrder,
};
typedef struct node{
void *Data;
struct node *pRight, *pLeft, *pFather;
bitset<8> Info;
} RBNode;
public:
TRBTree(int(*fnComp)(void*, void*), void(*getLabel)(void*, char*));
~TRBTree();
TraversingDir getTraversingDir();
void setTraversingDir(TraversingDir value);
void Insert(void *data);
bool Delete(void *data);
bool Destroy(void *data);
void *Search(void *data);
void Last();
void First();
void Prior();
void Next();
void *getCurrent();
void DeleteAll();
void DestroyAll();
int getCount();
bool GoToFather();
bool GoToLeft();
bool GoToRight();
bool GoToRoot();
bool Successor();
bool Antecessor();
void WriteGraphvizSource(FILE *f, bool blackwhite = true);
private:
void LeftRotate(RBNode *node);
void RightRotate(RBNode *node);
RBNode *pRoot, *pCurrent;
int FCount;
int (*pFnComp)(void*, void*);
void (*pFnGetLabel)(void*, char*);
TraversingDir FTraversingDir;
};
#endif