-
Annoying CArray problem!
I have a forward declaration in my header file - class CLogItemData and have the following also :
Code:
typedef CArray<CLogItemData*,CLogItemData*> logDetails;
this is declared outside my class
Code:
logDetails* m_logDetails;
this is declared as a private member of my class.
Now in my implementation file I have the following :
Code:
void CDialogReportPrintLog::LogDetails(logDetails& aryItemDataArray)
{
m_logDetails = &aryItemDataArray;
}
and in OnIntDialog I have the following :
Code:
CString strIDSFormat;
int nSize = m_logDetails->GetSize();
// Determine what time of fields are available to the user to filter
for (int nLoop = 0; nLoop < nSize; nLoop++)
{
CLogItemData* log = (CLogItemData*)m_logDetails->GetAt(nLoop);
if ((!m_bDateTime) && (log->m_lDateTime != 0))
{
strIDSFormat.FormatMessage(IDS_STRINGDATETIME);
m_bDateTime = !m_bDateTime;
}
m_comboSortFirstOrder.AddString(strIDSFormat);
}
when I do the following and examine the contents of log
Code:
CLogItemData* log = (CLogItemData*)m_logDetails->GetAt(nLoop);
its fine - I see all the data I need. However, if I do the following as well:
Code:
if ((!m_bDateTime) && (log->m_lDateTime != 0))
{
....
}
I get a really annoying error - error C2027: use of undefined type 'CLogItemData'
... see declaration of 'CLogItemData'
C:\dev\ivs2\source\DialogReportPrintLog.cpp(58) : error C2065: 'm_lDateTime' : undeclared identifier
1. How can it say that CLogItemData is undefined when I can GetAt() an element and also look at the contents of log?
2. and how can 'm_lDateTime' be undeclared when I can visiblely see it in the log object (which is defined as CLogItemData).
it does not like me doing log->m_lDateTime!!!
Can anyone see waht it is I'm missing here?
regards
John
-
do you include the header for CLogItemData in the
implementation file ? (DialogReportPrintLog.cpp)
-
No. If I do, I'll get circular compilation problems.
I've included my Dialog header file in a file that has two classes - one where I instantiate my dialog, and the other class is CLogItemData. Sounds like I should put CLogItemData into a file of its own as so to deal with this problem. good idea??
Regards
John
-
if i understand by but you ment by saying "circular compilation problems"
Check followingFAQ
-
Originally I used forward declarations... but thats where the problems started arising... please refer to my original posting for further details.
I've ended up putting the offending class into a file of its own and included in the header file thats common to both classes and its worked.
Regards
John