(1)当我把一个程序写作的三个文件时:头文件,函数文件(或类文件),main.cpp文件。执行main()文件能得出预期结果。但把工程关了后再打开(即把全部关了),这个时候我再去执行main发现老是有两个错误。不知为何?
(2)再发我的另外一段实际代码,也是两个错误,似乎是说我这没main()函数和no external什么的(家没网,我在网吧上,没编译器,应该就是上面两个错误)
#include "stdafx.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
int ret = MessageBox(NULL,TEXT("中国官员其实和封建地主没有什么区别,什么高层,全是屁话,基本就是一群暴发户在统治,靠垄断权力榨取人民的鲜血"),TEXT("统治者简介"),MB_YESNOCANCEL|MB_ICONQUESTION );
return 0;
}
下面代码是系统自动生成的,当我打开上面的文件时就说我有那两个错误。不知道为何?那么应该打开哪个文件呢?
stdafx.cpp
// stdafx.cpp : source file that includes just the standard includes
// 写一个界面N.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
stdafx.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)