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?

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

#include <iostream>

namespace z
{
	int x=0;
}
	
class Person 
{
	

public:

Person()
 {

	std::cout<<z::x;
}
};

int main()
{
	Person obj;
	return 0;
}

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

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

If they are in same directory then use
#include "Store.cpp" instead of <Store.cpp>

Oh, I see. I appreciate the help sunny.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.