Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Code won't compile

Posted on 1999-06-24
3
Medium Priority
?
255 Views
Last Modified: 2010-04-16
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)
0
Comment
Question by:darnison062499
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1198381
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?
0
 
LVL 6

Accepted Solution

by:
Triskelion earned 100 total points
ID: 1198382
#include "{the header file that contains the definition for CDVTestDoc}"


0
 

Author Comment

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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question