Solved

CView Inheritance

Posted on 1998-07-21
5
349 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
[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
  • 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

Independent Software Vendors: 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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

734 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