Click here to Skip to main content
15,916,693 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VoidNish Pin
Jack Puppy1-Apr-06 17:08
Jack Puppy1-Apr-06 17:08 
QuestionProblem with AfxMessageBox Pin
Laughing Buddha1-Apr-06 13:54
Laughing Buddha1-Apr-06 13:54 
AnswerRe: Problem with AfxMessageBox Pin
Saurabh.Garg1-Apr-06 16:18
Saurabh.Garg1-Apr-06 16:18 
GeneralRe: Problem with AfxMessageBox Pin
Laughing Buddha2-Apr-06 1:46
Laughing Buddha2-Apr-06 1:46 
GeneralRe: Problem with AfxMessageBox Pin
Saurabh.Garg2-Apr-06 5:20
Saurabh.Garg2-Apr-06 5:20 
Questionaccess and edit picture grabber for image processing Pin
den tewe1-Apr-06 9:27
den tewe1-Apr-06 9:27 
AnswerRe: access and edit picture grabber for image processing Pin
Saurabh.Garg1-Apr-06 16:20
Saurabh.Garg1-Apr-06 16:20 
Question= operator in CObject-derived classes Pin
Dr-Kuulun1-Apr-06 5:18
Dr-Kuulun1-Apr-06 5:18 
Hello,

I wrote one post this day to my problem. Now I am able to describe my problem more detailed. So once more:

I want to write a base class and a class that manage a list of objects derived from my base class. The list-class should have a = operator that copies the whole list and creates copies of all its elements (derived from base class).

The base class is derived from CObject because of serialisation and so on. It also includes some basic methods and members.

<br />
class CBase::Cobject<br />
{<br />
....<br />
}<br />


Now I derive some classes from it.

<br />
class CA::CBase<br />
{<br />
}<br />
<br />
class CB::CBase<br />
{<br />
}<br />
<br />


All classes should have a = operator to copy its elements!

The list-class now have a list of pointers to some instances from CA und CB in a CObArray.
The = operator of the list-class shoud create a copy of the list an the members.

<br />
CBase* pElement1;<br />
CBase* pElement2;<br />
CRuntimClass* pRTC;<br />
int nIndex;<br />
<br />
for (nIndex=0; nIndex<pList->GetCount(); nIndex++)<br />
{<br />
pElement1 = pList->GetAt(nIndex);<br />
pRTC = pElement1->GetRuntimeClass();<br />
pElement2 = (CBase*)pRTC->CreateObject();<br />
pRTC = pElement2->GetRuntimeClass();<br />
*pElement2 = *pElement1;<br />
Add(pElement2);<br />
}<br />
<br />


pList is a pointer to the source CObArray-Object.
Add() adds an element in the destination CObArray-Object.

Now the problem:
*pElement2 = *pElement1 do not call the = operator of CA or CB. The = operators have no virtual behaviour. The result ist that not all elements (CBase and CA/CB) are copied. Only the = operator of CBase is called.
What is to do? And how can i call in the = operator function of CA the = operator funrction of CBase to copy the base elements?


And one more question:
What is the reason for the Cxyz& return type of the = operators and the return(*this) statement?

Thanx


Dr-Kuulun
AnswerRe: = operator in CObject-derived classes Pin
Michael Dunn1-Apr-06 6:06
sitebuilderMichael Dunn1-Apr-06 6:06 
GeneralRe: = operator in CObject-derived classes Pin
Dr-Kuulun2-Apr-06 0:24
Dr-Kuulun2-Apr-06 0:24 
Questionproblem with openfile dialog api Pin
_tasleem1-Apr-06 2:31
_tasleem1-Apr-06 2:31 
AnswerRe: problem with openfile dialog api Pin
krmed1-Apr-06 3:22
krmed1-Apr-06 3:22 
GeneralRe: problem with openfile dialog api Pin
_tasleem1-Apr-06 4:18
_tasleem1-Apr-06 4:18 
AnswerRe: problem with openfile dialog api Pin
alicabas1-Apr-06 4:29
alicabas1-Apr-06 4:29 
QuestionProblem with CRecordset::GetFieldValue Pin
Vikrant for VC++1-Apr-06 2:19
Vikrant for VC++1-Apr-06 2:19 
QuestionHow to read Triggers of a Database Pin
Vikrant for VC++1-Apr-06 2:14
Vikrant for VC++1-Apr-06 2:14 
AnswerRe: How to read Triggers of a Database Pin
Vikrant for VC++1-Apr-06 3:15
Vikrant for VC++1-Apr-06 3:15 
GeneralRe: How to read Triggers of a Database Pin
Milton Karimbekallil1-Apr-06 4:13
Milton Karimbekallil1-Apr-06 4:13 
GeneralRe: How to read Triggers of a Database Pin
Vikrant for VC++1-Apr-06 4:18
Vikrant for VC++1-Apr-06 4:18 
GeneralRe: How to read Triggers of a Database Pin
includeh101-Apr-06 6:44
includeh101-Apr-06 6:44 
AnswerRe: How to read Triggers of a Database Pin
crazymubashir2-Apr-06 21:15
crazymubashir2-Apr-06 21:15 
QuestionAfter open a XML File how to print the data of XML File on Active Document Pin
Amit Agarrwal1-Apr-06 1:50
Amit Agarrwal1-Apr-06 1:50 
AnswerRe: After open a XML File how to print the data of XML File on Active Document Pin
Milton Karimbekallil1-Apr-06 2:50
Milton Karimbekallil1-Apr-06 2:50 
GeneralRe: After open a XML File how to print the data of XML File on Active Document Pin
Amit Agarrwal1-Apr-06 2:57
Amit Agarrwal1-Apr-06 2:57 
GeneralRe: After open a XML File how to print the data of XML File on Active Document Pin
Milton Karimbekallil1-Apr-06 4:09
Milton Karimbekallil1-Apr-06 4:09 

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.