darnison062499
asked on
Code won't compile
I wrote this code in Microsoft Visual C++ 6, I can not find any reasion for why it will to Compile.
The primary error message occures because the CDVTestDoc class in "CDVTestDoc* pDoc = (CDVTestDoc*)GetDocument() ;" is undeclared, yet ITS THERE!
Heres the Source;
CDVTestDoc* pDoc = (CDVTestDoc*)GetDocument() ;
ASSERT_VALID( pDoc );
CString szName;
m_edNames.SetWindowText( szName );
m_edNames.SetWindowText( "" );
m_edNames.SetFocus();
if( szNames.GetLength() > 0 )
{
int nIndex = pDoc->AddName( szName );
m_lbNames.InsertString( nIndex, szName );
m_lbNames.SetCurSel( nIndex );
}
Here are the error messages;
Compiling...
FormText.cpp
C:\vc\Source Library\DVTest\FormText.cp p(68) : error C2065: 'CDVTestDoc' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cp p(68) : error C2065: 'pDoc' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cp p(68) : error C2059: syntax error : ')'
C:\vc\Source Library\DVTest\FormText.cp p(74) : error C2065: 'szNames' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cp p(74) : error C2228: left of '.GetLength' must have class/struct/union type
C:\vc\Source Library\DVTest\FormText.cp p(76) : error C2227: left of '->AddName' must point to class/struct/union
Error executing cl.exe.
DVTest.exe - 6 error(s), 0 warning(s)
The primary error message occures because the CDVTestDoc class in "CDVTestDoc* pDoc = (CDVTestDoc*)GetDocument()
Heres the Source;
CDVTestDoc* pDoc = (CDVTestDoc*)GetDocument()
ASSERT_VALID( pDoc );
CString szName;
m_edNames.SetWindowText( szName );
m_edNames.SetWindowText( "" );
m_edNames.SetFocus();
if( szNames.GetLength() > 0 )
{
int nIndex = pDoc->AddName( szName );
m_lbNames.InsertString( nIndex, szName );
m_lbNames.SetCurSel( nIndex );
}
Here are the error messages;
Compiling...
FormText.cpp
C:\vc\Source Library\DVTest\FormText.cp
C:\vc\Source Library\DVTest\FormText.cp
C:\vc\Source Library\DVTest\FormText.cp
C:\vc\Source Library\DVTest\FormText.cp
C:\vc\Source Library\DVTest\FormText.cp
C:\vc\Source Library\DVTest\FormText.cp
Error executing cl.exe.
DVTest.exe - 6 error(s), 0 warning(s)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I didn't know I had to include the header file every time I call an external class.
Are you sure that CDVTestDoc is defined by that point in the source? Is it defined in an include file? Is that include file included? If you place a syntax error in the include file at the location where CDVTestDoc is defined, does the compiler report an error?