Solved

CView Inheritance

Posted on 1998-07-21
5
347 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 146
Excel Use VBA to get user's Mac Address for their computer 5 244
move a line in eclipse 3 107
canBalance challenge 34 98
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 …
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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