我在VC中自己定义了一个类,在这个类中需要使用本工程的视图类作为成员变量,我在头文件中都加入了Include视图类头文件的语句,但编译总是通不过,提示说我Include的文件过多,请问如何解决这个问题?谢了
解决方案 »
- ScrollConsoleScreenBuffer 函数的第三个参数
- 有人用过研华ARK-5280工控机看门狗吗
- windows下select模型
- 一个简单的小问题 马上就结贴~~~~
- error C2664: 'strcpy' : cannot convert parameter 1 from 'class CString' to 'char *'
- 谁有vc画图的例子源程序,给一个吧!
- 谁要手机程序的源代码
- 请问ATL高手控件一个问题
- 关于邮箱后缀域名的问题求助?不搭建服务器,如何将邮箱修改为指定域名?
- 怎么往 一个BUTTON 上画一个位图啊,用SDK!!
- 对SQL Sever的表中的数据分组合计,并最后总计!
- 请问编译通过的程序在运行时出错是什么原因?关于CMainFrame。
Specifies that the file will be included (opened) only once by the compiler in a build. This can reduce build times as the compiler will not open and read the file after the first #include of the module.For example,// header.h
#pragma once
#include "CxxxView.h"
我定义了class CTest
然后在里面定义成员变量CSDIView view1;
#include "SDIView.h"
还是有一个错误,
“error C2248: 'CSDIView::CSDIView' : cannot access protected member declared in class 'CSDIView'”
用菜单上面那个Add files to Project
STEP1:
在当前的工程目录中加入自己的定义的类!
为了简单起见,在类中使用的是视图类的指针变量,这样省去了修改视图的构造函数的麻烦!
//The project name is :TestWin.dsp//The file:test.h
class CTest
{
private:
CTestWinView *m_pView;
public:
CTest();
void SetView(CTestWinView *pView);
CTestWinView* GetView();
};//The file:test.cpp
#include "stdafx.h"//must include this file!
#include "TestWinDoc.h"
#include "TestWinView.h"
#include "Test.h"CTest::CTest()
{
m_pView=NULL;
}
CTestWinView* CTest::GetView()
{
return m_pView;
}
void CTest::SetView(CTestWinView *pView)
{
m_pView=pView;
}STEP2:
使用菜单Project->Add to project->files将文件test.h和test.cpp添加到工程中即可!
#include "stdafx.h"//must include this file!
#include "TestWinDoc.h"
#include "TestWinView.h"
#include "Test.h"------------------------
必须在
#inlude "test.h"之前,依次包含:
#include "stdafx.h"//must include this file!
#include "TestWinDoc.h"//used in the CTestWinView.h
#include "TestWinView.h"//used in the CTest