| | |
using your own namespace?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I have a class Person and a Class Store. I didn't find any way to really inherit Store in class Person, so I created Class Store in a namespace called StoreClass.
In the person class this doesn't work:
using namespace StoreClass;
it says that namespace StoreClass is undeclared.
I also tried to include the actual File which is called Store.cpp, but it says it couldn't find that either. Both classes are in the same directory.
Is there something I'm doing wrong?
In the person class this doesn't work:
using namespace StoreClass;
it says that namespace StoreClass is undeclared.
I also tried to include the actual File which is called Store.cpp, but it says it couldn't find that either. Both classes are in the same directory.
Is there something I'm doing wrong?
No need to add it in the class(not even allowed...i guess).....you can simply put it in global scope or use scope resolution operator...
example
example
C++ Syntax (Toggle Plain Text)
#include <iostream> namespace z { int x=0; } class Person { public: Person() { std::cout<<z::x; } }; int main() { Person obj; return 0; }
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
Well, I knew that would work, but I'm trying to split functionality up as much as I can. Is there not a way to have this Store class as an external source code and import it into the Person class?
I've tried this:
#include <Store>
and
#include <Store.cpp>
Both of which didn't work, but they are in the same directoryl
I've tried this:
#include <Store>
and
#include <Store.cpp>
Both of which didn't work, but they are in the same directoryl
•
•
•
•
Originally Posted by server_crash
Well, I knew that would work, but I'm trying to split functionality up as much as I can. Is there not a way to have this Store class as an external source code and import it into the Person class?
I've tried this:
#include <Store>
and
#include <Store.cpp>
Both of which didn't work, but they are in the same directoryl
#include "Store.cpp" instead of <Store.cpp>
![]() |
Similar Threads
- namespace controversy (IT Professionals' Lounge)
- create XML element with namespace (VB.NET)
- HelpProvider Namespace Problem (C#)
- <@ import Namespace "MathService"> , or was not found. (ASP.NET)
- help with namespace error (C++)
- Server error: namespace not found (ASP.NET)
Other Threads in the C++ Forum
- Previous Thread: Adding memberfunctions into a class?
- Next Thread: Open Source Projects
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count data database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






