Link to home
Start Free TrialLog in
Avatar of prain
prainFlag for United States of America

asked on

C++ Namespaces

I am testing this simple C++ namespace in netbeans.

I have this namespace.... in a ANameSpace.h file...
#ifndef ANAMESPACE_H
#define      ANAMESPACE_H

namespace ANameSpace
{
    class AClass
    {
    public:
         AClass() {
     this->aValue = 0;
}

 AClass(const AClass& orig) {
}

void  aMethod(int inValue){
    this->aValue = inValue;
}

  ~AClass() {
}
       
    private:
        int aValue;
    };
}

#endif      /* ANAMESPACE_H */



Then I have a small main() like this....

#include <cstdlib>
 
using namespace std;
using namespace ANameSpace;

int main(int argc, char** argv)
{
  ANameSpace::AClass aClass;
       
  return 0;
}

I am getting abuild error at line : using namespace ANameSpace;
main.cpp:19: error: `ANameSpace' has not been declared

and also in line : ANameSpace::AClass aClass;

 `ANameSpace' has not been declared

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prain

ASKER

OK. Thanks. I thought since they are all part of the same project, I do  not need to put the #inlude "ANameSpace.h"
Avatar of prain

ASKER

Thanks. Great.