.h文件内容:
#include <afx.h>class HelloDlg
{
private:
CString s;public:
void SetString(CString ls);
CString GetString();
}.cpp文件内容
#include "stdafx.h"
#include "hyf.h"
HelloDlg::HelloDlg()
{}
void HelloDlg::SetString(CString ls)
{
s=ls;
}CString HelloDlg::GetString()
{
return s;
}
编译后产生如下错误:
Compiling...
hyf.cpp
E:\VcDll\mydll\hyf.cpp(1) : warning C4651: '/D_DLL' specified for precompiled header but not for current compile
E:\VcDll\mydll\hyf.cpp(1) : warning C4651: '/D_AFXDLL' specified for precompiled header but not for current compile
E:\VcDll\mydll\hyf.cpp(6) : error C2533: 'HelloDlg::HelloDlg' : constructors not allowed a return type
E:\VcDll\mydll\hyf.cpp(6) : error C2084: function '__thiscall HelloDlg::HelloDlg(void)' already has a body
Error executing cl.exe.mydll.dll - 2 error(s), 2 warning(s)为什么?
#include <afx.h>class HelloDlg
{
private:
CString s;public:
void SetString(CString ls);
CString GetString();
}.cpp文件内容
#include "stdafx.h"
#include "hyf.h"
HelloDlg::HelloDlg()
{}
void HelloDlg::SetString(CString ls)
{
s=ls;
}CString HelloDlg::GetString()
{
return s;
}
编译后产生如下错误:
Compiling...
hyf.cpp
E:\VcDll\mydll\hyf.cpp(1) : warning C4651: '/D_DLL' specified for precompiled header but not for current compile
E:\VcDll\mydll\hyf.cpp(1) : warning C4651: '/D_AFXDLL' specified for precompiled header but not for current compile
E:\VcDll\mydll\hyf.cpp(6) : error C2533: 'HelloDlg::HelloDlg' : constructors not allowed a return type
E:\VcDll\mydll\hyf.cpp(6) : error C2084: function '__thiscall HelloDlg::HelloDlg(void)' already has a body
Error executing cl.exe.mydll.dll - 2 error(s), 2 warning(s)为什么?
解决方案 »
- 用C语言或者汇编语言实现多字节除法算法
- [我的2010]CSDN
- CPalette调色板的问题(回帖有分)
- 关于在对话框的绘图区域弹出工具提示(tooltip)问题
- ms h.263压缩视频ICSendMessage(m_hIC,0x60c9,0xf7329ace,0xacdeaea2)只能是176*144大小,有谁知道改变大小的方法???
- 散分~
- 在一个工程文件中,一个文件里面的参数怎么在另一个文件里面得到?
- 想从cobject继承,class wizard选项中没有,为什么这样设计?
- 请教各位 高手关于一个发音程序的编写.使用声卡发出给定频率的声音.谢谢!
- 求助!!!vc++调用ffmpeg视频转码
- 请问怎样才能在列表视图控件(ListCtrl)中查找数据,我用的是报表模式(REPORT),在线等待,回答有分
- 为什么D版的Vc++6.0安装不起,紧急!!
{
private:
CString s;public:
void SetString(CString ls);
CString GetString();
HelloDlg(); }
应该就可以了
类按你说的修改,cpp里面增加如下代码:
HelloDlg::HelloDlg()
{
}
但是还错,错误很奇怪:
E:\VcDll\mydll\hyf.cpp(4) : error C2533: 'HelloDlg::HelloDlg' : constructors not allowed a return type
但是构造函数是不应该有void前缀的。