Click here to Skip to main content
15,909,498 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: What I am trying to do Pin
Zac Howland31-Jul-06 10:57
Zac Howland31-Jul-06 10:57 
GeneralRe: Should I learn ATL/COM now? Pin
Kevin McFarlane31-Jul-06 10:52
Kevin McFarlane31-Jul-06 10:52 
GeneralRe: Should I learn ATL/COM now? Pin
Zac Howland31-Jul-06 11:11
Zac Howland31-Jul-06 11:11 
GeneralRe: Should I learn ATL/COM now? Pin
Kevin McFarlane1-Aug-06 0:42
Kevin McFarlane1-Aug-06 0:42 
GeneralTo Zac Pin
CPP_Student31-Jul-06 12:36
CPP_Student31-Jul-06 12:36 
Questionvector -- call methods from inheritance classes [modified] Pin
RealWood30-Jul-06 4:56
RealWood30-Jul-06 4:56 
GeneralRe: vector -- call methods from inheritance classes Pin
Justin Tay30-Jul-06 5:46
Justin Tay30-Jul-06 5:46 
GeneralRe: vector -- call methods from inheritance classes Pin
RealWood30-Jul-06 8:09
RealWood30-Jul-06 8:09 
Hi hfry,

thank you for your help. Your advise for the 'Base class pointer' works fine.

hfry: So what is the reason loadGUI isn't a virtual member of your Basis class?

The reason is, that I can't change the base class. The base class is from the Qt library (It's a QWidget class).
In my application I call for every QWidget object (like pointer object 'a') the appropriate method (like 'loadGUI()').
The result is like this:
a->loadGUI();
b->loadGUI();
c->loadGUI();
d->loadGUI();
...

I would like to have these calls in a for-loop where 'V' is the vector to the QWidget objects:
for (int i=0; i < V.size(); i++)
{
V[i]-loadGUI();
}

/////////////////////////////////////////////////////////////////////////////

class B : public Basis {
public:
virtual void reset(void);

void loadGUI(void);
};

void B::reset(void)
{
cout << "Class B reset ! \n";
}

void B::loadGUI(void)
{
cout <<"Class B loadGUI! \n";
}

....

vector<Basis*> V;

//Build up object a
A* a = new A();
V.push_back(a);

//Build up object b
B* b = new B();
V.push_back(b);

for(int i = 0; i <V.size(); i++)
{
V[i]->reset(); //It works fine.
}

//Now, try to call loadGUI()

//First version
A* a1 = static_cast<A*>(V[0]);
a1->loadGUI();

B* b1 = static_cast<B*>(V[1]);
b1->loadGUI();


//Second version
for(int i = 0; i <V.size(); i++)
{
// V[i]->loadGUI(); //It doesn't work.
}
/////////////////////////////////////////////////////////////////////////////

If there isn't a solution with STL, I will tried with design pattern (maybe the decorator pattern). But this is an other topic and doesn't belong to this forum.

Kinds regard,

Thomas
GeneralRe: vector -- call methods from inheritance classes [modified] Pin
Justin Tay30-Jul-06 10:37
Justin Tay30-Jul-06 10:37 
GeneralRe: vector -- call methods from inheritance classes [modified] Pin
Zac Howland31-Jul-06 9:03
Zac Howland31-Jul-06 9:03 
GeneralRe: vector -- call methods from inheritance classes Pin
RealWood31-Jul-06 11:32
RealWood31-Jul-06 11:32 
QuestionHow to CComBSTR convert to char *? Pin
alan top29-Jul-06 2:49
alan top29-Jul-06 2:49 
AnswerRe: How to CComBSTR convert to char *? Pin
Monty229-Jul-06 21:36
Monty229-Jul-06 21:36 
GeneralRe: How to CComBSTR convert to char *? Pin
Jörgen Sigvardsson30-Jul-06 9:21
Jörgen Sigvardsson30-Jul-06 9:21 
AnswerRe: How to CComBSTR convert to char *? Pin
Michael Dunn29-Jul-06 23:24
sitebuilderMichael Dunn29-Jul-06 23:24 
AnswerRe: How to CComBSTR convert to char *? Pin
Zac Howland31-Jul-06 8:37
Zac Howland31-Jul-06 8:37 
GeneralRe: How to CComBSTR convert to char *? Pin
Jörgen Sigvardsson1-Aug-06 12:27
Jörgen Sigvardsson1-Aug-06 12:27 
QuestionScrolling Woes. Pin
HakunaMatada28-Jul-06 23:21
HakunaMatada28-Jul-06 23:21 
AnswerRe: Scrolling Woes. Pin
Monty229-Jul-06 21:38
Monty229-Jul-06 21:38 
GeneralRe: Scrolling Woes. Pin
HakunaMatada30-Jul-06 18:40
HakunaMatada30-Jul-06 18:40 
QuestionAbout IE 7 Tabs Pin
JaydeepB26-Jul-06 21:46
JaydeepB26-Jul-06 21:46 
AnswerRe: About IE 7 Tabs Pin
JaydeepB27-Jul-06 21:25
JaydeepB27-Jul-06 21:25 
GeneralRe: About IE 7 Tabs Pin
HunterNet19-Aug-06 5:16
HunterNet19-Aug-06 5:16 
QuestionCoCreateInstance() return E_OUTOFMEMORY Pin
chenxiujie26-Jul-06 19:43
chenxiujie26-Jul-06 19:43 
NewsRe: CoCreateInstance() return E_OUTOFMEMORY Pin
Anonymuos28-Jul-06 12:06
Anonymuos28-Jul-06 12:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.