Solved

CView Inheritance

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

13 Experts available now in Live!

Get 1:1 Help Now