CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Using public variables of View class in a dialog clas

    I have written a prog. in which I have public data members in the View class. I have created a dialog box. I want to use public data members of View class in the implementation file (*.cpp) of dialog class. I have included the header file of view class. I am getting following error:
    *View.h error C2501: 'GetDocument": missing decl-specifiers "
    If I dont include the header file of view class then the above error is removed but the error of undefined variables remains their.
    The error is comming in *View.h file at following point:
    public:
    CStudentDoc* GetDocument();




  2. #2
    Join Date
    May 1999
    Posts
    48

    Re: Using public variables of View class in a dialog clas

    use forward declaration (class className instead include directive, or put ifdef,endif into your h.
    Sincerely, Mihai


  3. #3
    Guest

    Re: Using public variables of View class in a dialog clas

    I have the similiar problem and have tried all the solutions suggested by Mihai,
    but can't resolve the problem.
    #ifdef and #endif are already included by app wizard and forward declaration can't solve the problem.

    Everything goes fine but the line where I typecast my view class.


    m_strReply = ((CMyView*) m_pParent)->ProcessRequest(m_Editable);




    I pass the CMyView* in the dialog ( CDEditor )constructor and assigns it to m_pParent.
    like,

    CDEditor::CDEditor(CWnd* pParent /*=NULL*/)
    : CDialog(CDEditor::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CDEditor)
    //}}AFX_DATA_INIT
    m_pParent = pParent;
    }





  4. #4
    Join Date
    Apr 1999
    Posts
    383

    Re: Using public variables of View class in a dialog clas

    Have you got a declaration for CStudentDoc in view.h before the GetDocument declaration? A forward declaration will do:

    class CStudentDoc;
    CStudentDoc* GetDocument();

    Dave



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured