4 Replies - 292 Views - Last Post: 15 October 2012 - 08:07 AM Rate Topic: -----

#1 M-rhodes  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 131
  • Joined: 24-September 10

Implementing the same stack across multiple forms - help needed.

Posted 14 October 2012 - 11:34 AM

Hi, my application involves the use of a stack class, the stack is modified by another class by taking input. I wish to use another form to output elements of the same stack. I was wondering if scope was an issue?

e.g.
 InputStack inputStack = new InputStack();



That is the declaration of an instance of the stack within the form that takes input.

All help appreciated,

Matt

Is This A Good Question/Topic? 0
  • +

Replies To: Implementing the same stack across multiple forms - help needed.

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5441
  • View blog
  • Posts: 11,674
  • Joined: 02-June 10

Re: Implementing the same stack across multiple forms - help needed.

Posted 14 October 2012 - 12:20 PM

Why are you reinventing the wheel?
Is there any reason you can't use the existing Queue class, which works pretty much as you've described and allows you to push items onto the queue and pop them off?
Was This Post Helpful? 0
  • +
  • -

#3 M-rhodes  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 131
  • Joined: 24-September 10

Re: Implementing the same stack across multiple forms - help needed.

Posted 14 October 2012 - 12:49 PM

No there is nothing wrong with the class. Im trying to refer to an instance of the class that is declared on the input form from the output form.
I have done a temp work around using text file handling to store values.

This post has been edited by M-rhodes: 14 October 2012 - 12:49 PM

Was This Post Helpful? 0
  • +
  • -

#4 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1010
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Implementing the same stack across multiple forms - help needed.

Posted 14 October 2012 - 09:23 PM

Do a search for Singleton Pattern.
Was This Post Helpful? 1
  • +
  • -

#5 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,719
  • Joined: 08-June 10

Re: Implementing the same stack across multiple forms - help needed.

Posted 15 October 2012 - 08:07 AM

Singleton is the right answer, but make sure you create a separate class for it, don't declare it on your main form, because that tightly binds forms together.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1