Archived

This topic is now archived and is closed to further replies.

JoshG

Macro Protection? "Qualifier 'x' is not a class or Namespace"

Recommended Posts

JoshG    127
Hello, I recently read the posts in a thread hear on "Macro Protection" I think that is what it was referred to as. Anyways, I tried to implement it. But I don''t think it is the actual Macro Protection that is the problem... I used to have all the code in one .cpp file. I knew this was messy, and wanted to change it, so I made a .h file for a class, and put the implementation of the class in a .cpp file. Then I included the .h file into my mainfile Now, I get an error when compiling of "Qualifier ''x'' is not a class or Namespace". I''m sure this is common among newbies, So can anyone help me? I have it setup like this: MyExe.cpp:
  
#include "MyClass.h"
void main(){
}  
MyClass.h:
  
#ifndef _THIS_CLASS
#define _THIS_CLASS

class MyClass{
  public:
    MyClass();
    ~MyClass();
};
#endif  
MyClass.cpp
  
MyClass::MyClass(){
  //Do stuff

}
MyClass::~MyClass(){
  //Undo Stuff

}  
The lines I get errors on are the lines in "MyClass.cpp" beginning with "MyClass::" Any Help? Thanks --Josh

Share this post


Link to post
Share on other sites
JoshG    127
If I do that then I get errors in the file "MyClass.h" in defines of the class, All my pointers that are declared, ie:

class MyClass{
private:
static OtherClass *Obj;
}

Then I get an error saying "declaration missing ';'"
And yet all my ';' are there!!

ok, here is the propper declaration of the class:
    
class OOConsole{
public:
OOConsole();
~OOConsole();
static void ConsoleIn(char*); //Allows input to the console

static void ConsoleOut(char*); //Allows Output from console

static void Register(OOConsoleFunction*); //Identifies new commands

static void getBuffer(char*,int); //Retrieves Console output

static void clearBuffer(); //Removes all Console Output

static void clearLine(int); //Removes Output on a given line

static void LoadFile(char*); //Loads and executes commands from a file

static void Scan(char*,char**,char**); //Breaks up a commandline into words

private:
static char Lines[MAX_CONSOLE_LINES][MAX_CONSOLE_LEN]; //Array containing Output

static BTree *FuncMap; //Map of all commands

static int LinesFilled; //Position of Last Output

};


If I remove the '*' from the BTree, then it SEEMS to work...
But i don't want to remove it

--Josh

Edited by - JoshG on January 3, 2002 3:18:19 AM

Share this post


Link to post
Share on other sites
JonStelly    127
The error you''re getting is probably ''declaration missing before ;''? That means that you need to declare the variable type before you use it. You can either declare BTree before you use it, or include the header file that does that. Either:

  
class BTree;

class OOConsole
{
private:
static BTree* FuncMap;
}


or

  
#include "btree.h"

class OOConsole
{
private:
static BTree* FuncMap;
}

Share this post


Link to post
Share on other sites
JoshG    127
Well, The thing is, I have already included that file!
it is in the MyExe.cpp file
like so:

#include "BTree.cpp"
#include "Console.h"

or do I have to include it in the other as well?
If so, Wouldn''t that mean that I am declaring it twice?

Share this post


Link to post
Share on other sites
CaptainJester    523
Yes, you have to include the header file in every file that uses it. You then avoid multiple inclusion with:

#ifndef _THIS_CLASS
#define _THIS_CLASS
class MyClass{
public:
MyClass();
~MyClass();
};
#endif

---
Make it work.
Make it fast.

Share this post


Link to post
Share on other sites
JoshG    127
ahh,
damn, I don''t think any of you understand what is going on.
OK. I''ll start another thread and re-write the question, PROPER details will be in this one, includeing ALL Code.

So that is an indication to that moderator guy/girl to delete this thread as it isnt of any use

--Josh

Share this post


Link to post
Share on other sites