Click here to Skip to main content
15,899,679 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
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 
GeneralRe: vector -- call methods from inheritance classes [modified] Pin
Justin Tay30-Jul-06 10:37
Justin Tay30-Jul-06 10:37 
You might want to look into delegates, there should be a few articles on codeproject on this.

Alternatively, here's a hack. You might want to get a second opinion before doing this though.

struct ICommon
{
	virtual ~ICommon(){};
	virtual void loadGUI() = 0;
	virtual void reset() = 0;
};

template <class T, bool t_bManaged = true>
class Wrapper : public ICommon
{
public:
	Wrapper(T* pObject)
	{
		m_pObject = pObject;
	}

	~Wrapper()
	{
		if(t_bManaged) delete m_pObject;
	}

	void reset()
	{
		m_pObject->reset();
	}

	void loadGUI()
	{
		m_pObject->loadGUI();
	}

	T* m_pObject;
};

class A {
public:
	void reset(void)
	{
		cout << "Class A reset ! \n";
	}

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

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

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


vector<ICommon*> V;

V.push_back(new Wrapper<A>(new A));
V.push_back(new Wrapper(new B));

for(vector<ICommon*>::iterator i = V.begin(); i != V.end(); i++)
{
	(*i)->reset();
	(*i)->loadGUI();
}

for(vector<ICommon*>::iterator i = V.begin(); i != V.end(); i++)
{
	delete *i;
}



-- modified at 16:37 Sunday 30th July, 2006

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 
QuestionHow to convert *string to _bstr_t and *BSTR Pin
agarunk26-Jul-06 4:38
agarunk26-Jul-06 4:38 

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.