I want to simply create stack based objects but I have the following problem. I have a class which will contain a stack based static Queue. But I need to access it from my main.cpp source file, so I'm not sure how to declare it within my main.cpp file. If it's a stack based static queue, what do I write in my main.cpp? Also, what type of "Accessor" should I write for it in my class in order to get it. What's the return type of the "Accessor method? It shouldn't be a "*", should it? Do i return the "&" address of the stack based queue in order to access it in main? Then is that variable in main that references it a pointer? I'm a little confused..Also, as long as my main.cpp includes class A's header, can I call the accessor for the Queue inside main?
Code:
class A
{
public:
static Queue myQueue; //on the stack
Queue getMyQueue(); //accessor for it
}
Queue A::myQueue; //declare the stack variable
Queue A::getMyQueue()
{
return &Queue; //in order to access it out of the class and insert into it
}
main.cpp (assuming all proper header inclusions)
-----------
Queue myQueue; //want to access it and insert into it
myQueue = A::getMyQueue();
myQueue.insert( blah ); //in order to keep in stack based?