multiple namespaces

J

Jim Langston

how do you import multiple namespaces from the same header?

Please explain what you want. It could be as simple as:
using namespace name1;
using namespace name2;
 
B

bob

i'm thinking of something like this:

#include "matrixlib.h"
using namespace name1;
using namespace name2;

but i don't think that works.
 
O

osmium

i'm thinking of something like this:

#include "matrixlib.h"
using namespace name1;
using namespace name2;

but i don't think that works.

I'm not sure I know what you want. This works, does it help?

#include <iostream>
#include <cmath>

namespace abc {
//------------------------
// return the sine of an angle expressed in degrees
double sin(double th)
{
static const double pi = 3.14159;
return std::sin(th * pi / 180.);
}
} // end namespace abc

using namespace std;
//===================
int main()
{
cout << abc::sin(45.) << endl; // degrees
cout << std::sin(.98); // radians
cin.get();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top