Click here to Skip to main content
15,894,343 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question[Message Deleted] Pin
Gajendra Sharma21-Aug-09 2:28
Gajendra Sharma21-Aug-09 2:28 
Answer[Message Deleted] Pin
Gajendra Sharma21-Aug-09 2:34
Gajendra Sharma21-Aug-09 2:34 
GeneralRe: Can a client socket be bound to an IP address? Pin
Nemanja Trifunovic21-Aug-09 2:55
Nemanja Trifunovic21-Aug-09 2:55 
GeneralRe: Can a client socket be bound to an IP address? Pin
Rajesh R Subramanian21-Aug-09 2:57
professionalRajesh R Subramanian21-Aug-09 2:57 
GeneralRe: Can a client socket be bound to an IP address? Pin
Randor 21-Aug-09 3:06
professional Randor 21-Aug-09 3:06 
GeneralRe: Can a client socket be bound to an IP address? Pin
Gajendra Sharma21-Aug-09 3:09
Gajendra Sharma21-Aug-09 3:09 
QuestionIs it possible to load and use ocx in Vista Session 0? Pin
Sharath C V21-Aug-09 1:56
professionalSharath C V21-Aug-09 1:56 
Questionc++ Inheritance Question Pin
Rudi66621-Aug-09 0:21
Rudi66621-Aug-09 0:21 
Hello,

i have the following problem that i want to describe with codesnippets:

i have the class CGCxPageElement. Its the Base class of CGCxPane:

class CGCxPageElement : public CGCxHtmlTemplate {
	DECLARE_DYNCREATE(CGCxPageElement)

//*** CONSTRUCTORS ***
public:
	CGCxPageElement();

	CGCxPageElement(const CGCxPageElement &e) {
		m_strTemplate = e.m_strTemplate;
		m_strContent = e.m_strContent;
	}

	CGCxPageElement& operator=(const CGCxPageElement &e) { 
		m_strTemplate = e.m_strTemplate;
		m_strContent = e.m_strContent;
		
		return *this; 
	}

	virtual ~CGCxPageElement();

//*** MEMBERS ***
protected:
	CString m_strContent;

//*** METHODS ***
public:
	virtual void SetContent(CString strContent);
	virtual void SetContent(UINT nIDResource);
	virtual CString MakeHtml();
	
};


class CGCxPane : public CGCxPageElement {
	DECLARE_DYNCREATE(CGCxPane)

//*** CONSTRUCTORS ***
public:
	CGCxPane();

	CGCxPane(const CGCxPane &e) {
		m_strTemplate = e.m_strTemplate;
		m_strContent = e.m_strContent;
		m_strTitle = e.m_strTitle;
	}

	CGCxPane& operator=(const CGCxPane &e) { 
		m_strTemplate = e.m_strTemplate;
		m_strContent = e.m_strContent;
		m_strTitle = e.m_strTitle;
		
		return *this; 
	}

	virtual ~CGCxPane();

//*** MEMBERS ***
protected:
	CString m_strTitle;

//*** METHODS ***
public:
	//virtual void SetContent(CString strContent);
	//virtual void SetContent(UINT nIDResource);
	void SetTitle(CString strTitle);
	virtual CString MakeHtml();
	
};


then i have an array of CGCxPageElement objects. i have to add GCxPane and other Object inherited from CGCxPageElement to it:

CArray<CGCxPageElement, CGCxPageElement&> m_Elements;


now here comes the problem: inside another class i want to go through the CGCxPageElement array and call the method MakeHtml, but not that one of the base class but of the child e.g. CGCxPane

for (int i = 0; i < m_Elements.GetCount(); i++) {
CGCxPageElement elem = m_Elements[i];
// what to do here??
strContent.Append(elem.MakeHtml());
}


1. how can i find out what class is stored in m_Elements originally?
2. how can i call the MakeHtml() method of this class and not of the base class?

i am not a pro in inheritance...but for now i am stuck. any casting like

CGCxPane pane = (CGCxPane) m_Elements[i];


does not work and i don't want to hadrcode the CGCxPane inside because there will be some more CGCxPageElement object not only CGCxPane.

any help would be much appreciated!

regards,
rudi
AnswerRe: c++ Inheritance Question Pin
Cedric Moonen21-Aug-09 1:09
Cedric Moonen21-Aug-09 1:09 
GeneralRe: c++ Inheritance Question Pin
Rudi66621-Aug-09 1:54
Rudi66621-Aug-09 1:54 
AnswerRe: c++ Inheritance Question Pin
sashoalm21-Aug-09 1:12
sashoalm21-Aug-09 1:12 
QuestionVC++ Capture image using PMD Camera Pin
maherjas21-Aug-09 0:12
maherjas21-Aug-09 0:12 
AnswerRe: VC++ Capture image using PMD Camera Pin
Adam Roderick J21-Aug-09 1:08
Adam Roderick J21-Aug-09 1:08 
QuestionGetting file pointer (*FILE) Pin
Azghar Hussain20-Aug-09 23:51
professionalAzghar Hussain20-Aug-09 23:51 
AnswerRe: Getting file pointer (*FILE) Pin
sashoalm21-Aug-09 1:08
sashoalm21-Aug-09 1:08 
GeneralRe: Getting file pointer (*FILE) Pin
Azghar Hussain21-Aug-09 2:09
professionalAzghar Hussain21-Aug-09 2:09 
QuestionRasSetEntryProperties() function not working properly in vista. Pin
birajendu20-Aug-09 23:23
birajendu20-Aug-09 23:23 
QuestionURL encoding/decoding function for C++ Pin
sashoalm20-Aug-09 22:43
sashoalm20-Aug-09 22:43 
AnswerRe: URL encoding/decoding function for C++ Pin
Code-o-mat20-Aug-09 22:55
Code-o-mat20-Aug-09 22:55 
AnswerRe: URL encoding/decoding function for C++ Pin
Randor 20-Aug-09 22:55
professional Randor 20-Aug-09 22:55 
GeneralRe: URL encoding/decoding function for C++ Pin
sashoalm20-Aug-09 23:39
sashoalm20-Aug-09 23:39 
AnswerRe: URL encoding/decoding function for C++ Pin
Hristo-Bojilov20-Aug-09 22:57
Hristo-Bojilov20-Aug-09 22:57 
AnswerRe: URL encoding/decoding function for C++ Pin
Rajesh R Subramanian20-Aug-09 22:58
professionalRajesh R Subramanian20-Aug-09 22:58 
GeneralRe: URL encoding/decoding function for C++ Pin
sashoalm20-Aug-09 23:27
sashoalm20-Aug-09 23:27 
GeneralRe: URL encoding/decoding function for C++ Pin
Rajesh R Subramanian21-Aug-09 0:12
professionalRajesh R Subramanian21-Aug-09 0:12 

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.