Solved

CView Inheritance

Posted on 1998-07-21
5
345 Views
Last Modified: 2013-11-20
I am developing an application which has several views. All these views have some common attributes, so I need a class inherits from CView class and all the other views derived from this intermediate class. I put       DECLARE_DYNCREATE(CMyView)
DECLARE_MESSAGE_MAP()
in the derived class. But there are some link problems: error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const  CMyView::classCMyView" (?classCMyView@CMyView@@2UCRuntimeClass@@B).
Is it possible to have an intermediate class? How to do it?
0
Comment
Question by:mchen2
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
SamratAshok earned 80 total points
ID: 1319535
Yes, you can have as many classes as you want (or have time to write :-;)

Your error message has nothing to with the fact that you are deriving a layer.

Actually most common cause of that error is that you missed IMPLEMENT_DYNCREATE
macro, or even more common, did not supply right class names as macro arguments.

I have derived from a view for generic several times. As a personal rule I always make the
generic class abstract, though not strictly necessary.

In my latest code it looked something like this (using Formview)
class AFX_EXT_CLASS CGenericView : public CFormView
{
   protected:
      CGenericView(UINT nIDTemplate, char cDelim = DELIMITER);
      DECLARE_DYNAMIC(CGenericView)
   public:
      virtual ~CGenericView();
..
}

 in .CPP
make sure that you have

IMPLEMENT_DYNAMIC(CGenericView,CFormView)
with the right class names.

0
 

Author Comment

by:mchen2
ID: 1319536
Thank you, Mr. SamratAshok. It works. But it works only when I put the whole derived class in one header file. When I split the class into 2 parts, .h and .cpp files, there is compile error: unexpected file end encountered in the .cpp file. Could please tell me why? How to solve the problem.
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1319537

Thats strange ....

I usually get that error if  I missed stdafx.h include in the .cpp
or sometimes a semicolon at the end of class definition.

In either case you should get the error message if definition and declaration are  in same file.

Try stdafx and if it does not work include your code somehow (atleast all rel. pieces)

0
 

Author Comment

by:mchen2
ID: 1319538
I tried stdafx. I didn't work. And I have a semicolon at the end of class definition.

The error is at the end of the .cpp file:

fatal error C1010: unexpected end of file while looking for precompiled header directive


0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1319539
Post your code
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 48
Tab names are off by one 5 53
VBA "SendKeys" Syntax for Multiple Keystrokes 7 103
MaxSpan challenge 9 82
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now