Trying to make this as simple as possible. I have 30 or so classes that I need to get access to depending which one is showing. To make things easy, let's say I have three classes as members of another class:
Class1, Class2 and Class3.
I only show one at a time. All three have a method called "UpdateData." I need to make a call to UpdateData in whatever one is showing (or active).
How can I hold a reference to the active class so I can make the call? IE, instead of doing something like:
if (Class1.isActive)
Class1.UpdateData()
else if (Class2.isActive)
Class2.UpdateData()
Remember, I have 30 classes. I just want to hold the active class' reference somehow to call it only once. Something like:
ActiveClass[n].UpdateData()
I could add all of the classes in there and then hold the active class as an integer "n." I can't use Vector or anything because that requires a cast to use. I need the class to change. I can't figure this out. Thanks for any help.
2007-07-11
10:54:00
·
2 answers
·
asked by
JIM
1
in
Computers & Internet
➔ Programming & Design