Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CView Inheritance

Posted on 1998-07-21
5
Medium Priority
?
352 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 240 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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