prain
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Great.
ASKER