《深入浅出MFC》中源码编译为何出错?

linamu linamu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近在看《深入浅出MFC》,但是在编译随书的源码时却总是出错;例如第二章的Flow.cpp:
#include <iostream.h>
#include <string.h>

class CDemo
{
public:
CDemo(const char* str);
~CDemo();
private:
char name[20];
};

CDemo::CDemo(const char* str)
{
strncpy(name, str, 20);
cout << "Constructor called for " << name << '\n';
}

CDemo::~CDemo()
{
cout << "Destructor called for " << name << '\n';
}

void func()
{
CDemo LocalObjectInFunc("LocalObjectInFunc"); // in stack
static CDemo StaticObject("StaticObject"); // local static
CDemo* pHeapObjectInFunc = new CDemo("HeapObjectInFunc"); // in heap

cout << "Inside func" << endl;

}

CDemo GlobalObject("GlobalObject"); // global static

void main()
{
CDemo LocalObjectInMain("LocalObjectInMain"); // in stack
CDemo* pHeapObjectInMain = new CDemo("HeapObjectInMain"); // in heap

cout << "In main, before calling func\n";
func();
cout << "In main, after calling func\n";

}


出错提示是:
Compiling...
Flow.cpp
e:\深入浅出 mfc\dissect\flow.02\flow.cpp(27) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.

Flow.exe - 1 error(s), 0 warning(s)
用MSDN介绍的方法也解决不了,网上介绍的rebuild all 以及禁用预编译头文件也不行,请问各位请是怎么回事?我用的是Win98+VC6.0创天中文版,救救我啊!
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
linamu
VC/MFC 16,550 成员 421,606 内容