I want select.
Are you looking for something like this?
class CParent
{
public:
virtual void DoSomething() = NULL;
virtual void DoSomethingElse() = NULL;
};
class CChild1 : Parent
{
public:
virtual void DoSomething() ;
virtual void DoSomethingElse();
}
class CChild2 : Parent
{
public:
virtual void DoSomething() ;
virtual void DoSomethingElse();
}
void CSomeDialogBox::OnInitDialog()
{
CParent *pItem = NULL;
int Index = m_ComboBox.AddString("CChild1 Object");
pItem = new CChild1;
m_ComboBox.SetItemData(Index,pItem);
Index = m_ComboBox.AddString("CChild2 Object");
pItem = new CChild2;
m_ComboBox.SetItemData(Index,pItem);
}
void CSomeDialogBox::SomeEventHandler()
{
CParent *pItem = m_ComboBox.GetItemData(m_ComboBox.GetCurSel());
//this will call CChild1 or CChild2 depending on what's stored in the
item data of the combobox item
pItem->DoSomething();
}
AliR.
"Tio Cactus" <tomjey@wp.pl> wrote in message
news:1157127182.832907.309940@p79g2000cwp.googlegroups.com...
Tom Serface napisal(a):
If it were me I'd just create one class that does both,
but I have the same names of functions in both class and I can't do
this.
Using two classes is easier.
but if you really
need to have two different classes you can use "new" to create the
object
dynamically once the proper class is identified by the user using the
combo
box. The combo box will return an index that will help you identify the
class to use. You could check the return in an if of switch statement
pretty easily.
Only one time (on start program) I will select the class which I use
leter.
So when I select e.g."first case" in combobox I need only functions
from first class, without functions from second class. Some other
variables and global functions will in both case.
Can I write something like that...........
if Combobox retunt e.g. 'case 1'
MyFirstClass* Object = new MyFirstClass();
if Combobox retunt e.g. 'case 2'
MySecondClass* Object = new MySecondClass();
then I working on Object until I want close program.
and when program finishes 'delete' Object ? because I use this class
all time until I close program.
Is it correct ?