Hi guys,
I'm having trouble getting a namespace to work from within a class definition. I'm not entirely sure this is possible, but the ultimate goal is to create an object and pass it one of the enumerated values in its constructor. I've tried doing an it as below, but the compiler does not like that route.
If I take out the namespace statement, then, in the main driver, I can create an object by calling pqueue test(pqueue::FIFO) (or any of the other three values)... Is there a way to do this with namespaces, so I can simply call pqueue test(FIFO)?
Thanks!!
-Max
class definintion - printQueue.h
Class implementation - printQueue.cppCode:#include <iostream>
using namespace std;
class pqueue
{
public:
namespace p
{
enum pTypes {FIFO, JOBSIZE, PRIORITY}; //used for naming which type of printer
}
pqueue(pTypes type);
private:
pTypes printer_type; //which type of printer this is
job *front; //front of the queue
job *back; //end of the queue
};
Program driver -- test.cppCode:#include <iostream>
#include "printQueue.h"
using namespace std;
pqueue::pqueue(pTypes type)
{
printer_type = type;
front = NULL;
back = NULL;
}
Code:#include <iostream>
#include "printQueue.h"
using namespace std;
using namespace p;
int main()
{
pqueue test(FIFO);
}