Link to home
Start Free TrialLog in
Avatar of darnison062499
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.cpp(68) : error C2065: 'CDVTestDoc' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cpp(68) : error C2065: 'pDoc' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cpp(68) : error C2059: syntax error : ')'
C:\vc\Source Library\DVTest\FormText.cpp(74) : error C2065: 'szNames' : undeclared identifier
C:\vc\Source Library\DVTest\FormText.cpp(74) : error C2228: left of '.GetLength' must have class/struct/union type
C:\vc\Source Library\DVTest\FormText.cpp(76) : error C2227: left of '->AddName' must point to class/struct/union
Error executing cl.exe.

DVTest.exe - 6 error(s), 0 warning(s)
Avatar of nietod
nietod

Can you post the code that comes before that?

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?
ASKER CERTIFIED SOLUTION
Avatar of Triskelion
Triskelion
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darnison062499

ASKER

Thanks, I didn't know I had to include the header file every time I call an external class.